From 460c5af6ea343ef5685b716413d01d7a30fa9acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elisi=C3=A1rio=20Couto?= Date: Wed, 24 Sep 2025 23:58:43 +0100 Subject: [PATCH] fix: Correct sync trigger types from manual to scheduled/retry. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed scheduled syncs being incorrectly saved as "manual" in database. Now properly identifies scheduled syncs as "scheduled" and retry attempts as "retry". Updated frontend to capitalize trigger type badges for better display. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- frontend/src/components/System.tsx | 4 ++-- leggen/api/models/sync.py | 2 +- leggen/background/scheduler.py | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/System.tsx b/frontend/src/components/System.tsx index a81e993..019c465 100644 --- a/frontend/src/components/System.tsx +++ b/frontend/src/components/System.tsx @@ -210,7 +210,7 @@ export default function System() { : "Sync Failed"} - {operation.trigger_type} + {operation.trigger_type.charAt(0).toUpperCase() + operation.trigger_type.slice(1)}
@@ -272,7 +272,7 @@ export default function System() { : "Sync Failed"} - {operation.trigger_type} + {operation.trigger_type.charAt(0).toUpperCase() + operation.trigger_type.slice(1)}
diff --git a/leggen/api/models/sync.py b/leggen/api/models/sync.py index abea474..ac03da3 100644 --- a/leggen/api/models/sync.py +++ b/leggen/api/models/sync.py @@ -18,7 +18,7 @@ class SyncOperation(BaseModel): duration_seconds: Optional[float] = None errors: list[str] = [] logs: list[str] = [] - trigger_type: str = "manual" # manual, scheduled, api + trigger_type: str = "manual" # manual, scheduled, retry, api class Config: json_encoders = {datetime: lambda v: v.isoformat() if v else None} diff --git a/leggen/background/scheduler.py b/leggen/background/scheduler.py index bfd380a..bbbcec3 100644 --- a/leggen/background/scheduler.py +++ b/leggen/background/scheduler.py @@ -102,12 +102,14 @@ class BackgroundScheduler: async def _run_sync(self, retry_count: int = 0): """Run sync with enhanced error handling and retry logic""" try: - logger.info("Starting scheduled sync job") - await self.sync_service.sync_all_accounts() - logger.info("Scheduled sync job completed successfully") + trigger_type = "retry" if retry_count > 0 else "scheduled" + logger.info(f"Starting {trigger_type} sync job") + await self.sync_service.sync_all_accounts(trigger_type=trigger_type) + logger.info(f"{trigger_type.capitalize()} sync job completed successfully") except Exception as e: + trigger_type = "retry" if retry_count > 0 else "scheduled" logger.error( - f"Scheduled sync job failed (attempt {retry_count + 1}/{self.max_retries}): {e}" + f"{trigger_type.capitalize()} sync job failed (attempt {retry_count + 1}/{self.max_retries}): {e}" ) # Send notification about the failure