?
TRCKR-191
bug sync
Created: 2025-12-08 Updated: 2025-12-16
Relationships Loading...
Attachments
Loading...
Comments (1)
agent · 2025-12-08
Fixed counter sync issue by adding _recalculate_counters() method to SyncEngine. ## Problem Found The client's counters table was never updated during sync. When the server created issues with identifiers like TRCKR-1, TRCKR-2, etc., the client would receive and insert these issues, but the local counter remained at 0. This caused UNIQUE constraint violations when the client tried to create new issues locally. ## Code Changes **File: client/sync.py** 1. Added `_recalculate_counters()` method (lines 1060-1121): - Recalculates global issue counter (TRCKR-N) by finding highest identifier - Recalculates per-project counters (PROJECT-N) for each project - Uses SQL to extract numeric portion of identifiers and update counters table 2. Modified `sync()` method (line 427-429): - Calls `_recalculate_counters()` after applying server changes - Only recalculates if changes were received **File: tests/test_counter_sync.py** (new file): - Added comprehensive tests for counter recalculation - Tests both global and per-project counter scenarios - Verifies no UNIQUE constraint violations after sync ## Testing All tests pass: - tests/test_counter_sync.py: 2/2 passed - tests/test_issue.py: 73/73 passed - tests/test_project.py: 53/53 passed - tests/test_docker.py: 5/5 passed (8 skipped) ## Verification The fix ensures that after sync, the local counter values match the highest identifier numbers seen in synced entities, preventing conflicts when creating new issues locally.