overviews.rb 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. overview_role = Role.find_by(name: 'Agent')
  2. Overview.create_if_not_exists(
  3. name: 'My assigned Tickets',
  4. link: 'my_assigned',
  5. prio: 1000,
  6. role_ids: [overview_role.id],
  7. condition: {
  8. 'ticket.state_id' => {
  9. operator: 'is',
  10. value: Ticket::State.by_category(:open).pluck(:id),
  11. },
  12. 'ticket.owner_id' => {
  13. operator: 'is',
  14. pre_condition: 'current_user.id',
  15. },
  16. },
  17. order: {
  18. by: 'created_at',
  19. direction: 'ASC',
  20. },
  21. view: {
  22. d: %w[title customer group created_at],
  23. s: %w[title customer group created_at],
  24. m: %w[number title customer group created_at],
  25. view_mode_default: 's',
  26. },
  27. )
  28. Overview.create_if_not_exists(
  29. name: 'Unassigned & Open',
  30. link: 'all_unassigned',
  31. prio: 1010,
  32. role_ids: [overview_role.id],
  33. condition: {
  34. 'ticket.state_id' => {
  35. operator: 'is',
  36. value: Ticket::State.by_category(:work_on_all).pluck(:id),
  37. },
  38. 'ticket.owner_id' => {
  39. operator: 'is',
  40. pre_condition: 'not_set',
  41. },
  42. },
  43. order: {
  44. by: 'created_at',
  45. direction: 'ASC',
  46. },
  47. view: {
  48. d: %w[title customer group created_at],
  49. s: %w[title customer group created_at],
  50. m: %w[number title customer group created_at],
  51. view_mode_default: 's',
  52. },
  53. )
  54. Overview.create_if_not_exists(
  55. name: 'My pending reached Tickets',
  56. link: 'my_pending_reached',
  57. prio: 1020,
  58. role_ids: [overview_role.id],
  59. condition: {
  60. 'ticket.state_id' => {
  61. operator: 'is',
  62. value: Ticket::State.by_category(:pending_reminder).pluck(:id),
  63. },
  64. 'ticket.owner_id' => {
  65. operator: 'is',
  66. pre_condition: 'current_user.id',
  67. },
  68. 'ticket.pending_time' => {
  69. operator: 'within next (relative)',
  70. value: 0,
  71. range: 'minute',
  72. },
  73. },
  74. order: {
  75. by: 'created_at',
  76. direction: 'ASC',
  77. },
  78. view: {
  79. d: %w[title customer group created_at],
  80. s: %w[title customer group created_at],
  81. m: %w[number title customer group created_at],
  82. view_mode_default: 's',
  83. },
  84. )
  85. Overview.create_if_not_exists(
  86. name: 'Open',
  87. link: 'all_open',
  88. prio: 1030,
  89. role_ids: [overview_role.id],
  90. condition: {
  91. 'ticket.state_id' => {
  92. operator: 'is',
  93. value: Ticket::State.by_category(:work_on_all).pluck(:id),
  94. },
  95. },
  96. order: {
  97. by: 'created_at',
  98. direction: 'ASC',
  99. },
  100. view: {
  101. d: %w[title customer group state owner created_at],
  102. s: %w[title customer group state owner created_at],
  103. m: %w[number title customer group state owner created_at],
  104. view_mode_default: 's',
  105. },
  106. )
  107. Overview.create_if_not_exists(
  108. name: 'Pending reached',
  109. link: 'all_pending_reached',
  110. prio: 1040,
  111. role_ids: [overview_role.id],
  112. condition: {
  113. 'ticket.state_id' => {
  114. operator: 'is',
  115. value: Ticket::State.by_category(:pending_reminder).pluck(:id),
  116. },
  117. 'ticket.pending_time' => {
  118. operator: 'within next (relative)',
  119. value: 0,
  120. range: 'minute',
  121. },
  122. },
  123. order: {
  124. by: 'created_at',
  125. direction: 'ASC',
  126. },
  127. view: {
  128. d: %w[title customer group owner created_at],
  129. s: %w[title customer group owner created_at],
  130. m: %w[number title customer group owner created_at],
  131. view_mode_default: 's',
  132. },
  133. )
  134. Overview.create_if_not_exists(
  135. name: 'Escalated',
  136. link: 'all_escalated',
  137. prio: 1050,
  138. role_ids: [overview_role.id],
  139. condition: {
  140. 'ticket.escalation_at' => {
  141. operator: 'within next (relative)',
  142. value: '10',
  143. range: 'minute',
  144. },
  145. },
  146. order: {
  147. by: 'escalation_at',
  148. direction: 'ASC',
  149. },
  150. view: {
  151. d: %w[title customer group owner escalation_at],
  152. s: %w[title customer group owner escalation_at],
  153. m: %w[number title customer group owner escalation_at],
  154. view_mode_default: 's',
  155. },
  156. )
  157. Overview.create_if_not_exists(
  158. name: 'My replacement Tickets',
  159. link: 'my_replacement_tickets',
  160. prio: 1080,
  161. role_ids: [overview_role.id],
  162. out_of_office: true,
  163. condition: {
  164. 'ticket.state_id' => {
  165. operator: 'is',
  166. value: Ticket::State.by_category(:open).pluck(:id),
  167. },
  168. 'ticket.out_of_office_replacement_id' => {
  169. operator: 'is',
  170. pre_condition: 'current_user.id',
  171. },
  172. },
  173. order: {
  174. by: 'created_at',
  175. direction: 'DESC',
  176. },
  177. view: {
  178. d: %w[title customer group owner escalation_at],
  179. s: %w[title customer group owner escalation_at],
  180. m: %w[number title customer group owner escalation_at],
  181. view_mode_default: 's',
  182. },
  183. )
  184. overview_role = Role.find_by(name: 'Customer')
  185. Overview.create_if_not_exists(
  186. name: 'My Tickets',
  187. link: 'my_tickets',
  188. prio: 1100,
  189. role_ids: [overview_role.id],
  190. condition: {
  191. 'ticket.state_id' => {
  192. operator: 'is',
  193. value: Ticket::State.by_category(:viewable).pluck(:id),
  194. },
  195. 'ticket.customer_id' => {
  196. operator: 'is',
  197. pre_condition: 'current_user.id',
  198. },
  199. },
  200. order: {
  201. by: 'created_at',
  202. direction: 'DESC',
  203. },
  204. view: {
  205. d: %w[title customer state created_at],
  206. s: %w[number title state created_at],
  207. m: %w[number title state created_at],
  208. view_mode_default: 's',
  209. },
  210. )
  211. Overview.create_if_not_exists(
  212. name: 'My Organization Tickets',
  213. link: 'my_organization_tickets',
  214. prio: 1200,
  215. role_ids: [overview_role.id],
  216. organization_shared: true,
  217. condition: {
  218. 'ticket.state_id' => {
  219. operator: 'is',
  220. value: Ticket::State.by_category(:viewable).pluck(:id),
  221. },
  222. 'ticket.organization_id' => {
  223. operator: 'is',
  224. pre_condition: 'current_user.organization_id',
  225. },
  226. },
  227. order: {
  228. by: 'created_at',
  229. direction: 'DESC',
  230. },
  231. view: {
  232. d: %w[title customer state created_at],
  233. s: %w[number title customer state created_at],
  234. m: %w[number title customer state created_at],
  235. view_mode_default: 's',
  236. },
  237. )