overviews.rb 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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: 'before (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: 'My subscribed Tickets',
  87. link: 'my_subscribed_tickets',
  88. prio: 1025,
  89. role_ids: [overview_role.id],
  90. condition: { 'ticket.mention_user_ids'=>{ 'operator' => 'is', 'pre_condition' => 'current_user.id', 'value' => '', 'value_completion' => '' } },
  91. order: {
  92. by: 'created_at',
  93. direction: 'ASC',
  94. },
  95. view: {
  96. d: %w[title customer group created_at],
  97. s: %w[title customer group created_at],
  98. m: %w[number title customer group created_at],
  99. view_mode_default: 's',
  100. },
  101. )
  102. Overview.create_if_not_exists(
  103. name: 'Open',
  104. link: 'all_open',
  105. prio: 1030,
  106. role_ids: [overview_role.id],
  107. condition: {
  108. 'ticket.state_id' => {
  109. operator: 'is',
  110. value: Ticket::State.by_category(:work_on_all).pluck(:id),
  111. },
  112. },
  113. order: {
  114. by: 'created_at',
  115. direction: 'ASC',
  116. },
  117. view: {
  118. d: %w[title customer group state owner created_at],
  119. s: %w[title customer group state owner created_at],
  120. m: %w[number title customer group state owner created_at],
  121. view_mode_default: 's',
  122. },
  123. )
  124. Overview.create_if_not_exists(
  125. name: 'Pending reached',
  126. link: 'all_pending_reached',
  127. prio: 1040,
  128. role_ids: [overview_role.id],
  129. condition: {
  130. 'ticket.state_id' => {
  131. operator: 'is',
  132. value: Ticket::State.by_category(:pending_reminder).pluck(:id),
  133. },
  134. 'ticket.pending_time' => {
  135. operator: 'before (relative)',
  136. value: 0,
  137. range: 'minute',
  138. },
  139. },
  140. order: {
  141. by: 'created_at',
  142. direction: 'ASC',
  143. },
  144. view: {
  145. d: %w[title customer group owner created_at],
  146. s: %w[title customer group owner created_at],
  147. m: %w[number title customer group owner created_at],
  148. view_mode_default: 's',
  149. },
  150. )
  151. Overview.create_if_not_exists(
  152. name: 'Escalated',
  153. link: 'all_escalated',
  154. prio: 1050,
  155. role_ids: [overview_role.id],
  156. condition: {
  157. 'ticket.escalation_at' => {
  158. operator: 'till (relative)',
  159. value: '10',
  160. range: 'minute',
  161. },
  162. },
  163. order: {
  164. by: 'escalation_at',
  165. direction: 'ASC',
  166. },
  167. view: {
  168. d: %w[title customer group owner escalation_at],
  169. s: %w[title customer group owner escalation_at],
  170. m: %w[number title customer group owner escalation_at],
  171. view_mode_default: 's',
  172. },
  173. )
  174. Overview.create_if_not_exists(
  175. name: 'My replacement Tickets',
  176. link: 'my_replacement_tickets',
  177. prio: 1080,
  178. role_ids: [overview_role.id],
  179. out_of_office: true,
  180. condition: {
  181. 'ticket.state_id' => {
  182. operator: 'is',
  183. value: Ticket::State.by_category(:open).pluck(:id),
  184. },
  185. 'ticket.out_of_office_replacement_id' => {
  186. operator: 'is',
  187. pre_condition: 'current_user.id',
  188. },
  189. },
  190. order: {
  191. by: 'created_at',
  192. direction: 'DESC',
  193. },
  194. view: {
  195. d: %w[title customer group owner escalation_at],
  196. s: %w[title customer group owner escalation_at],
  197. m: %w[number title customer group owner escalation_at],
  198. view_mode_default: 's',
  199. },
  200. )
  201. overview_role = Role.find_by(name: 'Customer')
  202. Overview.create_if_not_exists(
  203. name: 'My Tickets',
  204. link: 'my_tickets',
  205. prio: 1100,
  206. role_ids: [overview_role.id],
  207. condition: {
  208. 'ticket.state_id' => {
  209. operator: 'is',
  210. value: Ticket::State.by_category(:viewable).pluck(:id),
  211. },
  212. 'ticket.customer_id' => {
  213. operator: 'is',
  214. pre_condition: 'current_user.id',
  215. },
  216. },
  217. order: {
  218. by: 'created_at',
  219. direction: 'DESC',
  220. },
  221. view: {
  222. d: %w[title customer state created_at],
  223. s: %w[number title state created_at],
  224. m: %w[number title state created_at],
  225. view_mode_default: 's',
  226. },
  227. )
  228. Overview.create_if_not_exists(
  229. name: 'My Organization Tickets',
  230. link: 'my_organization_tickets',
  231. prio: 1200,
  232. role_ids: [overview_role.id],
  233. organization_shared: true,
  234. condition: {
  235. 'ticket.state_id' => {
  236. operator: 'is',
  237. value: Ticket::State.by_category(:viewable).pluck(:id),
  238. },
  239. 'ticket.organization_id' => {
  240. operator: 'is',
  241. pre_condition: 'current_user.organization_id',
  242. },
  243. },
  244. order: {
  245. by: 'created_at',
  246. direction: 'DESC',
  247. },
  248. view: {
  249. d: %w[title customer state created_at],
  250. s: %w[number title customer state created_at],
  251. m: %w[number title customer state created_at],
  252. view_mode_default: 's',
  253. },
  254. )