Class: ScheduleWorkers::DeleteOldInventories
- Inherits:
-
ApplicationWorker
- Object
- ApplicationWorker
- ScheduleWorkers::DeleteOldInventories
- Defined in:
- app/workers/schedule_workers/delete_old_inventories.rb
Overview
ScheduleWorkers::DeleteOldInventories This worker is responsible for cleaning up old inventory-related records from the database. It uses pt-archiver to efficiently purge data from large tables based on business rules.
Methods:
- perform: Main entry point, calls all cleanup methods.
- delete_old_sevenrooms_inv_sync_triggers: Cleans up SevenRooms inventory sync triggers older than 1 month.
- delete_old_tablecheck_inv_sync_triggers: Cleans up Tablecheck inventory sync triggers older than 1 month.
- delete_old_bistrochat_inv_sync_triggers: Cleans up Bistrochat inventory sync triggers older than 1 month.
- delete_old_restaurant_inventories: Cleans up various inventory tables older than 2 days.
- delete_old_audited_records: Cleans up audit records older than 3 months.
- delete_old_package_inventories: Cleans up package inventories older than today.
- delete_old_inventory_reservations: Cleans up inventory reservations for old reservations.
- build_pt_archiver_command: Helper to build pt-archiver command.
- execute_pt_archiver: Executes the archiver command and reports errors to APM.
Error Handling:
- All errors are reported using APMErrorHandler.report for monitoring and diagnostics.
- No Rails.logger.error is used; only APMErrorHandler for error reporting.
Edge Cases:
- If a command fails, it is reported to APM with the command details.
- All archiving operations are idempotent and safe to run multiple times.
Constant Summary collapse
- INVENTORY_CLASSES =
[ Inventory, InventoryTakeAway, InventoryTablecheck, InventorySevenRooms, InventoryBistrochat, InventoryMyMenu, ].freeze
Instance Method Summary collapse
-
#perform ⇒ Object
Main entry point for the worker.
Methods inherited from ApplicationWorker
Instance Method Details
#perform ⇒ Object
Main entry point for the worker. Calls all cleanup methods.
37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/workers/schedule_workers/delete_old_inventories.rb', line 37 def perform delete_old_generic_notes delete_old_audited_records delete_old_inventory_reservations delete_old_restaurant_inventories delete_old_tablecheck_inv_sync_triggers delete_old_bistrochat_inv_sync_triggers delete_old_sevenrooms_inv_sync_triggers delete_outdated_doorkeep_tokens end |