iachat/spec/jobs/internal
Vishnu Narayanan 688218de0a
feat: distributed scheduling for version check job (#13042)
This change spreads Chatwoot Hub version checks across the day by
scheduling each installation at a stable minute derived from its
installation identifier, instead of having all instances check at the
same fixed time.

Closes
-
https://linear.app/chatwoot/issue/CW-6107/handle-the-spike-at-12-utc-on-chatwoot-hub

What changed
- Added `Internal::TriggerDailyScheduledItemsJob` to act as the daily
trigger for deferred internal jobs.
- Updated the version check cron entry to run once daily at `00:00 UTC`
and enqueue the actual version check for that installation’s assigned
minute of the day.
- Used a deterministic minute-of-day derived from
`ChatwootHub.installation_identifier` so the check time stays stable
across deploys and restarts.
- Kept the existing cron schedule key while switching it to the new
orchestrator job.

How to test
- Run `bundle exec rspec
spec/jobs/internal/check_new_versions_job_spec.rb
spec/jobs/internal/trigger_daily_scheduled_items_job_spec.rb
spec/configs/schedule_spec.rb`
- In a Rails console, run
`Internal::TriggerDailyScheduledItemsJob.perform_now` and verify
`Internal::CheckNewVersionsJob` is enqueued with a `wait_until` later
the same UTC day.
- In Super Admin settings, use Refresh and verify the version check
still runs immediately.

---------

Co-authored-by: Sojan Jose <sojan@pepalo.com>
2026-03-17 02:27:49 -07:00
..
check_new_versions_job_spec.rb chore: Reorganize the installation config settings (#8794) 2024-01-31 16:48:42 +04:00
delete_accounts_job_spec.rb feat: automate account deletion (#11406) 2025-05-23 12:58:13 +05:30
process_stale_contacts_job_spec.rb fix: throttle stalecontacts job (#11430) 2025-05-08 20:05:08 -07:00
process_stale_redis_keys_job_spec.rb fix: RemoveStaleRedisKeys service (#10562) 2024-12-11 03:38:25 +08:00
remove_stale_contacts_job_spec.rb chore: use housekeeping queue for remove_stale_contacts job (#11435) 2025-05-08 09:39:49 +05:30
remove_stale_redis_keys_job_spec.rb fix: RemoveStaleRedisKeys service (#10562) 2024-12-11 03:38:25 +08:00
trigger_daily_scheduled_items_job_spec.rb feat: distributed scheduling for version check job (#13042) 2026-03-17 02:27:49 -07:00