20220124141828_overview_updates.rb 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class OverviewUpdates < ActiveRecord::Migration[6.0]
  3. def change
  4. return if !Setting.exists?(name: 'system_init_done')
  5. # Only update overviews that still have the original/default name and link.
  6. overviews_update = [
  7. {
  8. name: 'My Assigned Tickets',
  9. link: 'my_assigned',
  10. old_name: 'My assigned Tickets',
  11. },
  12. {
  13. name: 'Unassigned & Open Tickets',
  14. link: 'all_unassigned',
  15. old_name: 'Unassigned & Open',
  16. },
  17. {
  18. name: 'My Pending Reached Tickets',
  19. link: 'my_pending_reached',
  20. old_name: 'My pending reached Tickets',
  21. },
  22. {
  23. name: 'My Subscribed Tickets',
  24. link: 'my_subscribed_tickets',
  25. old_name: 'My subscribed Tickets',
  26. },
  27. {
  28. name: 'Open Tickets',
  29. link: 'all_open',
  30. old_name: 'Open',
  31. },
  32. {
  33. name: 'Pending Reached Tickets',
  34. link: 'all_pending_reached',
  35. old_name: 'Pending reached',
  36. },
  37. {
  38. name: 'Escalated Tickets',
  39. link: 'all_escalated',
  40. old_name: 'Escalated',
  41. },
  42. {
  43. name: 'My Replacement Tickets',
  44. link: 'my_replacement_tickets',
  45. old_name: 'My replacement Tickets',
  46. },
  47. ]
  48. overviews_update.each do |overview|
  49. fetched_overview = Overview.find_by(link: overview[:link], name: overview[:old_name])
  50. next if !fetched_overview
  51. if overview[:name]
  52. # p "Updating name of #{overview[:link]} to #{overview[:name]}"
  53. fetched_overview.name = overview[:name]
  54. end
  55. fetched_overview.save!
  56. end
  57. end
  58. end