20220124132029_scheduler_updates.rb 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class SchedulerUpdates < ActiveRecord::Migration[6.0]
  3. def change
  4. return if !Setting.exists?(name: 'system_init_done')
  5. schedulers_update = [
  6. {
  7. name: 'Clean up ActiveJob locks.',
  8. method: 'ActiveJobLockCleanupJob.perform_now',
  9. },
  10. {
  11. name: "Clean up 'HttpLog'.",
  12. method: 'HttpLog.cleanup',
  13. },
  14. {
  15. name: 'Clean up closed sessions.',
  16. method: 'Chat.cleanup',
  17. },
  18. {
  19. name: 'Clean up dead sessions.',
  20. method: 'SessionTimeoutJob.perform_now',
  21. },
  22. {
  23. name: 'Clean up expired sessions.',
  24. method: 'SessionHelper.cleanup_expired',
  25. },
  26. {
  27. name: 'Close chat sessions where participants are offline.',
  28. method: 'Chat.cleanup_close',
  29. },
  30. {
  31. name: "Generate 'Session' data.",
  32. method: 'Sessions.jobs',
  33. },
  34. {
  35. name: 'Generate user-based stats.',
  36. method: 'Stats.generate',
  37. },
  38. {
  39. name: 'Sync calendars with iCal feeds.',
  40. method: 'Calendar.sync',
  41. },
  42. {
  43. name: "Clean up 'Cti::Log.'",
  44. method: 'Cti::Log.cleanup',
  45. },
  46. {
  47. name: 'Execute import jobs.',
  48. method: 'ImportJob.start_registered',
  49. },
  50. {
  51. name: 'Process pending tickets.',
  52. method: 'Ticket.process_pending',
  53. },
  54. {
  55. name: 'Process ticket escalations.',
  56. method: 'Ticket.process_escalation',
  57. },
  58. {
  59. name: 'Process automatic ticket unassignments.',
  60. method: 'Ticket.process_auto_unassign',
  61. },
  62. {
  63. name: 'Check channels.',
  64. method: 'Channel.fetch',
  65. },
  66. {
  67. name: "Check 'Channel' streams.",
  68. method: 'Channel.stream',
  69. },
  70. {
  71. name: 'Execute planned jobs.',
  72. method: 'Job.run',
  73. },
  74. {
  75. name: "Delete old 'RecentView' entries.",
  76. method: 'RecentView.cleanup',
  77. },
  78. ]
  79. schedulers_update.each do |scheduler|
  80. fetched_scheduler = Scheduler.find_by(method: scheduler[:method])
  81. next if !fetched_scheduler
  82. if scheduler[:name]
  83. # p "Updating name of #{scheduler[:name]} to #{scheduler[:name]}"
  84. fetched_scheduler.name = scheduler[:name]
  85. end
  86. fetched_scheduler.save!
  87. end
  88. end
  89. end