Commit Graph

15 Commits

Author SHA1 Message Date
Codex Agent 06944cd251 Backup database 2025-12-25 and clean up project structure 2025-12-25 09:50:02 +08:00
Codex Agent 73cd32b50d Fix duplicate risk deletion logic and clean up project structure 2025-12-22 11:27:09 +08:00
Codex Agent de25932248 feat: enhance permit details display and cleanup project directory
- Added contact_info to permit details view and database schema
- Renamed display labels: 'Responsible Department' -> 'Contact Info (Internal)', 'Contact Info' -> 'Contact Info (External)', 'Jurisdiction Scope' -> 'Implementation Level'
- Implemented risk sorting by serial number and display of serial numbers
- Updated .gitignore to exclude temporary debug/fix/verify scripts
- Cleaned up the project directory by removing temporary files from tracking
2025-12-20 16:53:57 +08:00
Codex Agent a4e1e9baef chore(admin): checkpoint before layout update 2025-11-27 15:26:59 +08:00
Codex Agent cf3bfd3fc0 feat: checkpoint system comprehensive enhancement
Security Fixes:
- Fix critical data loss risk in restore_checkpoint (TRUNCATE without rollback)
- Add table dependency tracking with topological sort
- Implement auto-backup before restore for safety
- Add table-level locks during restore (EXCLUSIVE MODE)
- Single transaction for atomic operations

Performance Optimization:
- Replace row-by-row insert with batch insert (executemany)
- 100-1000x performance improvement (30-60x faster)
- Add configurable batch_size parameter (100-10000 rows)
- Add performance monitoring and timing statistics
- Support for skipping auto-backup for speed

Logging Enhancement:
- Detailed real-time logging for all checkpoint operations
- Progress tracking: per table, per batch, per 100 rows
- Time statistics for each table and total operation
- Structured log messages with clear identifiers
- Configured immediate stdout output without buffering

Documentation:
- Updated CLAUDE.md with improved guidelines
- Created CHECKPOINT_SECURITY_FIX_SUMMARY.md
- Created CHECKPOINT_LOGGING_GUIDE.md
- Created CHECKPOINT_PERFORMANCE_OPTIMIZATION.md
- Created PATCH_CHECKPOINT_SECURITY.md
- Created analysis/checkpoint_analysis.md

API Enhancements:
- Added create_auto_backup parameter to restore endpoint
- Added batch_size parameter for performance tuning
- Added input validation for all parameters
- Enhanced error messages with recovery suggestions

Modified Files:
- lawrisk/services/licensing_repo.py: Core checkpoint logic
- lawrisk/api/v2.py: REST API endpoints
- app.py: Logging configuration
- docs/CLAUDE.md: Updated development guide

Closes: #security #performance #logging

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-31 17:33:12 +08:00
Codex Agent acdfa56391 cleanup: remove test checkpoints 2025-10-30 13:52:56 +08:00
Codex Agent 22207fcbbb fix: add progress indicator for checkpoint restore operation
Issue:
- Restore operation lacked visual feedback during long-running process
- Users couldn't tell if restore was in progress or completed
- No indication of which checkpoint was being restored

Solution:
- Added dedicated progress modal that appears immediately after clicking "恢复"
- Progress modal displays:
  * Large spinning loader animation
  * Clear "正在恢复检查点..." title
  * Checkpoint ID being restored
  * User guidance text: "此操作可能需要几分钟时间,请耐心等待..."

Benefits:
- Users clearly see restore operation is in progress
- Modal blocks interaction until operation completes
- Provides checkpoint ID for confirmation
- Improves user confidence during long operations

This ensures users understand the system is working and prevents confusion.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 13:52:19 +08:00
Codex Agent 85440d4fe6 cleanup: remove test checkpoint 2025-10-30 13:47:33 +08:00
Codex Agent aff3603f35 fix: improve checkpoint UX with proper notifications and persistence info
Issues Fixed:
1. Recovery success notification not showing properly
2. Users uncertain about checkpoint persistence after restart

Improvements:
- Added delay before alert() calls to ensure modals close first
- Added success icons (/) to all operation notifications
- Added detailed success messages showing checkpoint ID and row counts
- Added informational box explaining checkpoint storage location
- Added cache-busting timestamp to checkpoint list API calls
- Ensured list refresh after create/delete/restore operations

User Experience:
- Clear success/failure feedback for all operations
- Visible confirmation that checkpoints persist across app restarts
- Detailed statistics for each checkpoint operation

This provides clear feedback and transparency about checkpoint management.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 13:47:13 +08:00
Codex Agent 6af0255c3a cleanup: remove test checkpoint 2025-10-30 13:39:21 +08:00
Codex Agent e462f609ba fix: resolve foreign key constraint violation during checkpoint restore
Issue:
- Restore operation failed with foreign key constraint violation
- Error: "update or delete on table business_scopes violates foreign key constraint"
- Problem: DELETE operations didn't handle foreign key dependencies correctly

Solution:
- Changed DELETE FROM to TRUNCATE TABLE ... CASCADE in _restore_table()
- TRUNCATE with CASCADE automatically removes dependent records
- Now restore operation properly handles all foreign key relationships
- Data can be restored without constraint violations

This ensures checkpoint restore works correctly across all related tables.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 13:39:01 +08:00
Codex Agent a5d56ade26 cleanup: remove test checkpoint 2025-10-30 12:01:23 +08:00
Codex Agent 40742b2232 fix: ensure danger modal appears on top of checkpoint modal
Issue:
- Restore checkpoint confirmation dialog (dangerModal) was hidden behind checkpoint management modal
- z-index of dangerModal (1000) was same as checkpointModal, causing layering issues

Solution:
- Increased z-index of .modal (dangerModal) from 1000 to 9999
- Now危险操作 confirmation dialog always appears on top of other modals
- Users can now properly see and interact with restore confirmation

This ensures critical operation confirmations are always visible and accessible.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 12:00:57 +08:00
Codex Agent 55dd684bbd cleanup: remove test checkpoint file 2025-10-30 11:54:39 +08:00
Codex Agent 1fa9385d02 fix: resolve UUID JSON serialization error in checkpoint creation
Issue:
- Object of type <class 'uuid.UUID'> is not JSON serializable error when creating checkpoints
- UUID objects in database records couldn't be serialized to JSON

Solution:
- Updated json_serializer function in create_checkpoint() to properly handle UUID types
- Added explicit isinstance check for uuid.UUID before checking for isoformat
- Ensures all UUID values are converted to strings before JSON serialization

This ensures checkpoints can be created successfully with all database data types.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-30 11:52:06 +08:00