#103 feat: auto sync times

Closed
opened 4 months ago by fszontagh · 2 comments

Fix the stores autosync time to the next schedule time always the next round hour.

For example if the store registered at 11:36h, the next scheduled time must be 12:00h.

Update the current stores too to sync in the next hour.

Fix the stores autosync time to the next schedule time always the next round hour. For example if the store registered at 11:36h, the next scheduled time must be 12:00h. Update the current stores too to sync in the next hour.
claude commented 4 months ago
Collaborator

@fszontagh I'm starting work on this issue now!

I'll:

  1. Update the calculate_next_sync_time function to always round up to the next full hour
  2. Create a migration to update all existing stores to sync at the next round hour
  3. Ensure new stores also get scheduled for the next round hour

This will ensure all auto-sync schedules align to round hours (e.g., 12:00, 13:00, etc.) regardless of registration time.

@fszontagh I'm starting work on this issue now! I'll: 1. Update the `calculate_next_sync_time` function to always round up to the next full hour 2. Create a migration to update all existing stores to sync at the next round hour 3. Ensure new stores also get scheduled for the next round hour This will ensure all auto-sync schedules align to round hours (e.g., 12:00, 13:00, etc.) regardless of registration time.
claude commented 4 months ago
Collaborator

Implementation Complete

@fszontagh I've successfully implemented the auto sync time fix! Here's what was done:

Changes Made

1. Updated calculate_next_sync_time() Function

The function now rounds up to the next appropriate time mark based on sync frequency:

  • hourly: Always syncs at :00 (e.g., 11:00, 12:00, 13:00)
  • 30min: Syncs at :00 or :30 (e.g., 11:00, 11:30, 12:00)
  • 15min: Syncs at :00, :15, :30, :45
  • 6hours: Syncs at 00:00, 06:00, 12:00, 18:00
  • daily: Syncs at 00:00 (next midnight)

2. Updated All Existing Stores

All active stores have been updated to sync at the next round hour.

Verification Results:

  • ✅ WooCommerce store (woo.aicaller.hu): Next sync at 11:00:00 UTC
  • ✅ ShopRenter store (smartboticsapptest): Next sync at 11:00:00 UTC

Both stores are now scheduled to sync at the next full hour mark instead of their original registration times.

Example Behavior

Before: Store registered at 11:36h → Next sync at 12:36h After: Store registered at 11:36h → Next sync at 12:00h

Files Changed

  • Migration: supabase/migrations/20251120_fix_next_sync_round_hour.sql
  • Applied to database: Migration successfully executed
  • Git commit: 243314e pushed to main branch

The migration has been applied to the production database and all existing stores are now synchronized to round hour marks!

✅ **Implementation Complete** @fszontagh I've successfully implemented the auto sync time fix! Here's what was done: ## Changes Made ### 1. Updated `calculate_next_sync_time()` Function The function now rounds up to the next appropriate time mark based on sync frequency: - **hourly**: Always syncs at `:00` (e.g., 11:00, 12:00, 13:00) - **30min**: Syncs at `:00` or `:30` (e.g., 11:00, 11:30, 12:00) - **15min**: Syncs at `:00`, `:15`, `:30`, `:45` - **6hours**: Syncs at `00:00`, `06:00`, `12:00`, `18:00` - **daily**: Syncs at `00:00` (next midnight) ### 2. Updated All Existing Stores All active stores have been updated to sync at the next round hour. **Verification Results:** - ✅ WooCommerce store (`woo.aicaller.hu`): Next sync at `11:00:00` UTC - ✅ ShopRenter store (`smartboticsapptest`): Next sync at `11:00:00` UTC Both stores are now scheduled to sync at the next full hour mark instead of their original registration times. ## Example Behavior **Before:** Store registered at `11:36h` → Next sync at `12:36h` **After:** Store registered at `11:36h` → Next sync at `12:00h` ✨ ## Files Changed - **Migration**: `supabase/migrations/20251120_fix_next_sync_round_hour.sql` - **Applied to database**: Migration successfully executed - **Git commit**: `243314e` pushed to main branch The migration has been applied to the production database and all existing stores are now synchronized to round hour marks!
Sign in to join this conversation.
No Milestone
No assignee
2 Participants
Loading...
Cancel
Save
There is no content yet.