report_test.rb 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358
  1. require 'test_helper'
  2. class ReportTest < ActiveSupport::TestCase
  3. include SearchindexHelper
  4. setup do
  5. configure_elasticsearch(required: true)
  6. Ticket.destroy_all
  7. rebuild_searchindex
  8. group1 = Group.lookup(name: 'Users')
  9. group2 = Group.create!(
  10. name: 'Report Test',
  11. updated_by_id: 1,
  12. created_by_id: 1
  13. )
  14. @ticket1 = Ticket.create!(
  15. title: 'test 1',
  16. group: group2,
  17. customer_id: 2,
  18. state: Ticket::State.lookup(name: 'new'),
  19. priority: Ticket::Priority.lookup(name: '2 normal'),
  20. created_at: '2015-10-28 09:30:00 UTC',
  21. updated_at: '2015-10-28 09:30:00 UTC',
  22. updated_by_id: 1,
  23. created_by_id: 1,
  24. )
  25. Ticket::Article.create!(
  26. ticket_id: @ticket1.id,
  27. from: 'some_sender@example.com',
  28. to: 'some_recipient@example.com',
  29. subject: 'some subject',
  30. message_id: 'some@id',
  31. body: 'some message article_inbound',
  32. internal: false,
  33. sender: Ticket::Article::Sender.where(name: 'Customer').first,
  34. type: Ticket::Article::Type.where(name: 'email').first,
  35. created_at: '2015-10-28 09:30:00 UTC',
  36. updated_at: '2015-10-28 09:30:00 UTC',
  37. updated_by_id: 1,
  38. created_by_id: 1,
  39. )
  40. @ticket1.tag_add('aaa', 1)
  41. @ticket1.tag_add('bbb', 1)
  42. @ticket1.update!(
  43. group: Group.lookup(name: 'Users'),
  44. updated_at: '2015-10-28 14:30:00 UTC',
  45. )
  46. @ticket2 = Ticket.create!(
  47. title: 'test 2',
  48. group: group1,
  49. customer_id: 2,
  50. state: Ticket::State.lookup(name: 'new'),
  51. priority: Ticket::Priority.lookup(name: '2 normal'),
  52. created_at: '2015-10-28 09:30:01 UTC',
  53. updated_at: '2015-10-28 09:30:01 UTC',
  54. updated_by_id: 1,
  55. created_by_id: 1,
  56. )
  57. Ticket::Article.create!(
  58. ticket_id: @ticket2.id,
  59. from: 'some_sender@example.com',
  60. to: 'some_recipient@example.com',
  61. subject: 'some subject',
  62. message_id: 'some@id',
  63. body: 'some message article_inbound',
  64. internal: false,
  65. sender: Ticket::Article::Sender.where(name: 'Customer').first,
  66. type: Ticket::Article::Type.where(name: 'email').first,
  67. created_at: '2015-10-28 09:30:01 UTC',
  68. updated_at: '2015-10-28 09:30:01 UTC',
  69. updated_by_id: 1,
  70. created_by_id: 1,
  71. )
  72. @ticket2.tag_add('aaa', 1)
  73. @ticket2.update!(
  74. group_id: group2.id,
  75. updated_at: '2015-10-28 14:30:00 UTC',
  76. )
  77. @ticket3 = Ticket.create!(
  78. title: 'test 3',
  79. group: group1,
  80. customer_id: 2,
  81. state: Ticket::State.lookup(name: 'open'),
  82. priority: Ticket::Priority.lookup(name: '3 high'),
  83. created_at: '2015-10-28 10:30:00 UTC',
  84. updated_at: '2015-10-28 10:30:00 UTC',
  85. updated_by_id: 1,
  86. created_by_id: 1,
  87. )
  88. Ticket::Article.create!(
  89. ticket_id: @ticket3.id,
  90. from: 'some_sender@example.com',
  91. to: 'some_recipient@example.com',
  92. subject: 'some subject',
  93. message_id: 'some@id',
  94. body: 'some message article_inbound',
  95. internal: false,
  96. sender: Ticket::Article::Sender.where(name: 'Customer').first,
  97. type: Ticket::Article::Type.where(name: 'email').first,
  98. created_at: '2015-10-28 10:30:00 UTC',
  99. updated_at: '2015-10-28 10:30:00 UTC',
  100. updated_by_id: 1,
  101. created_by_id: 1,
  102. )
  103. @ticket4 = Ticket.create!(
  104. title: 'test 4',
  105. group: group1,
  106. customer_id: 2,
  107. state: Ticket::State.lookup(name: 'closed'),
  108. priority: Ticket::Priority.lookup(name: '2 normal'),
  109. close_at: '2015-10-28 11:30:00 UTC',
  110. created_at: '2015-10-28 10:30:01 UTC',
  111. updated_at: '2015-10-28 10:30:01 UTC',
  112. updated_by_id: 1,
  113. created_by_id: 1,
  114. )
  115. Ticket::Article.create!(
  116. ticket_id: @ticket4.id,
  117. from: 'some_sender@example.com',
  118. to: 'some_recipient@example.com',
  119. subject: 'some subject',
  120. message_id: 'some@id',
  121. body: 'some message article_inbound',
  122. internal: false,
  123. sender: Ticket::Article::Sender.where(name: 'Customer').first,
  124. type: Ticket::Article::Type.where(name: 'email').first,
  125. created_at: '2015-10-28 10:30:01 UTC',
  126. updated_at: '2015-10-28 10:30:01 UTC',
  127. updated_by_id: 1,
  128. created_by_id: 1,
  129. )
  130. @ticket5 = Ticket.create!(
  131. title: 'test 5',
  132. group: group1,
  133. customer_id: 2,
  134. state: Ticket::State.lookup(name: 'closed'),
  135. priority: Ticket::Priority.lookup(name: '3 high'),
  136. close_at: '2015-10-28 11:40:00 UTC',
  137. created_at: '2015-10-28 11:30:00 UTC',
  138. updated_at: '2015-10-28 11:30:00 UTC',
  139. updated_by_id: 1,
  140. created_by_id: 1,
  141. )
  142. Ticket::Article.create!(
  143. ticket_id: @ticket5.id,
  144. from: 'some_sender@example.com',
  145. to: 'some_recipient@example.com',
  146. subject: 'some subject',
  147. message_id: 'some@id',
  148. body: 'some message article_outbound',
  149. internal: false,
  150. sender: Ticket::Article::Sender.where(name: 'Agent').first,
  151. type: Ticket::Article::Type.where(name: 'email').first,
  152. created_at: '2015-10-28 11:30:00 UTC',
  153. updated_at: '2015-10-28 11:30:00 UTC',
  154. updated_by_id: 1,
  155. created_by_id: 1,
  156. )
  157. @ticket5.tag_add('bbb', 1)
  158. @ticket5.update!(
  159. state: Ticket::State.lookup(name: 'open'),
  160. updated_at: '2015-10-28 14:30:00 UTC',
  161. )
  162. @ticket6 = Ticket.create!(
  163. title: 'test 6',
  164. group: group1,
  165. customer_id: 2,
  166. state: Ticket::State.lookup(name: 'closed'),
  167. priority: Ticket::Priority.lookup(name: '2 normal'),
  168. close_at: '2015-10-31 12:35:00 UTC',
  169. created_at: '2015-10-31 12:30:00 UTC',
  170. updated_at: '2015-10-31 12:30:00 UTC',
  171. updated_by_id: 1,
  172. created_by_id: 1,
  173. )
  174. Ticket::Article.create!(
  175. ticket_id: @ticket6.id,
  176. from: 'some_sender@example.com',
  177. to: 'some_recipient@example.com',
  178. subject: 'some subject',
  179. message_id: 'some@id',
  180. body: 'some message article_outbound',
  181. internal: false,
  182. sender: Ticket::Article::Sender.where(name: 'Agent').first,
  183. type: Ticket::Article::Type.where(name: 'email').first,
  184. created_at: '2015-10-31 12:30:00 UTC',
  185. updated_at: '2015-10-31 12:30:00 UTC',
  186. updated_by_id: 1,
  187. created_by_id: 1,
  188. )
  189. @ticket7 = Ticket.create!(
  190. title: 'test 7',
  191. group: group1,
  192. customer_id: 2,
  193. state: Ticket::State.lookup(name: 'closed'),
  194. priority: Ticket::Priority.lookup(name: '2 normal'),
  195. close_at: '2015-11-01 12:30:00 UTC',
  196. created_at: '2015-11-01 12:30:00 UTC',
  197. updated_at: '2015-11-01 12:30:00 UTC',
  198. updated_by_id: 1,
  199. created_by_id: 1,
  200. )
  201. Ticket::Article.create!(
  202. ticket_id: @ticket7.id,
  203. from: 'some_sender@example.com',
  204. to: 'some_recipient@example.com',
  205. subject: 'some subject',
  206. message_id: 'some@id',
  207. body: 'some message article_outbound',
  208. internal: false,
  209. sender: Ticket::Article::Sender.where(name: 'Agent').first,
  210. type: Ticket::Article::Type.where(name: 'email').first,
  211. created_at: '2015-11-01 12:30:00 UTC',
  212. updated_at: '2015-11-01 12:30:00 UTC',
  213. updated_by_id: 1,
  214. created_by_id: 1,
  215. )
  216. @ticket8 = Ticket.create!(
  217. title: 'test 8',
  218. group: group1,
  219. customer_id: 2,
  220. state: Ticket::State.lookup(name: 'merged'),
  221. priority: Ticket::Priority.lookup(name: '2 normal'),
  222. close_at: '2015-11-02 12:30:00 UTC',
  223. created_at: '2015-11-02 12:30:00 UTC',
  224. updated_at: '2015-11-02 12:30:00 UTC',
  225. updated_by_id: 1,
  226. created_by_id: 1,
  227. )
  228. Ticket::Article.create!(
  229. ticket_id: @ticket8.id,
  230. from: 'some_sender@example.com',
  231. to: 'some_recipient@example.com',
  232. subject: 'some subject',
  233. message_id: 'some@id',
  234. body: 'some message article_outbound',
  235. internal: false,
  236. sender: Ticket::Article::Sender.where(name: 'Agent').first,
  237. type: Ticket::Article::Type.where(name: 'email').first,
  238. created_at: '2015-11-02 12:30:00 UTC',
  239. updated_at: '2015-11-02 12:30:00 UTC',
  240. updated_by_id: 1,
  241. created_by_id: 1,
  242. )
  243. @ticket9 = Ticket.create!(
  244. title: 'test 9',
  245. group: group1,
  246. customer_id: 2,
  247. state: Ticket::State.lookup(name: 'open'),
  248. priority: Ticket::Priority.lookup(name: '2 normal'),
  249. close_at: '2037-11-02 12:30:00 UTC',
  250. created_at: '2037-11-02 12:30:00 UTC',
  251. updated_at: '2037-11-02 12:30:00 UTC',
  252. updated_by_id: 1,
  253. created_by_id: 1,
  254. )
  255. Ticket::Article.create!(
  256. ticket_id: @ticket9.id,
  257. from: 'some_sender@example.com',
  258. to: 'some_recipient@example.com',
  259. subject: 'some subject',
  260. message_id: 'some@id',
  261. body: 'some message article_outbound',
  262. internal: false,
  263. sender: Ticket::Article::Sender.where(name: 'Agent').first,
  264. type: Ticket::Article::Type.where(name: 'email').first,
  265. created_at: '2037-11-02 12:30:00 UTC',
  266. updated_at: '2037-11-02 12:30:00 UTC',
  267. updated_by_id: 1,
  268. created_by_id: 1,
  269. )
  270. # execute background jobs
  271. Scheduler.worker(true)
  272. end
  273. test 'compare' do
  274. # first solution
  275. result = Report::TicketFirstSolution.aggs(
  276. range_start: '2015-01-01T00:00:00Z',
  277. range_end: '2015-12-31T23:59:59Z',
  278. interval: 'month', # year, quarter, month, week, day, hour, minute, second
  279. selector: {}, # ticket selector to get only a collection of tickets
  280. )
  281. assert(result)
  282. assert_equal(0, result[0])
  283. assert_equal(0, result[1])
  284. assert_equal(0, result[2])
  285. assert_equal(0, result[3])
  286. assert_equal(0, result[4])
  287. assert_equal(0, result[5])
  288. assert_equal(0, result[6])
  289. assert_equal(0, result[7])
  290. assert_equal(0, result[8])
  291. assert_equal(2, result[9])
  292. assert_equal(1, result[10])
  293. assert_equal(0, result[11])
  294. assert_nil(result[12])
  295. result = Report::TicketFirstSolution.items(
  296. range_start: '2015-01-01T00:00:00Z',
  297. range_end: '2015-12-31T23:59:59Z',
  298. selector: {}, # ticket selector to get only a collection of tickets
  299. )
  300. assert(result)
  301. assert_equal(@ticket5.id, result[:ticket_ids][0])
  302. assert_equal(@ticket6.id, result[:ticket_ids][1])
  303. assert_equal(@ticket7.id, result[:ticket_ids][2])
  304. assert_nil(result[:ticket_ids][3])
  305. # month - with selector #1
  306. result = Report::TicketFirstSolution.aggs(
  307. range_start: '2015-01-01T00:00:00Z',
  308. range_end: '2015-12-31T23:59:59Z',
  309. interval: 'month', # year, quarter, month, week, day, hour, minute, second
  310. selector: {
  311. 'ticket.priority_id' => {
  312. 'operator' => 'is',
  313. 'value' => [Ticket::Priority.lookup(name: '3 high').id],
  314. }
  315. }, # ticket selector to get only a collection of tickets
  316. )
  317. assert(result)
  318. assert_equal(0, result[0])
  319. assert_equal(0, result[1])
  320. assert_equal(0, result[2])
  321. assert_equal(0, result[3])
  322. assert_equal(0, result[4])
  323. assert_equal(0, result[5])
  324. assert_equal(0, result[6])
  325. assert_equal(0, result[7])
  326. assert_equal(0, result[8])
  327. assert_equal(1, result[9])
  328. assert_equal(0, result[10])
  329. assert_equal(0, result[11])
  330. assert_nil(result[12])
  331. result = Report::TicketFirstSolution.items(
  332. range_start: '2015-01-01T00:00:00Z',
  333. range_end: '2015-12-31T23:59:59Z',
  334. selector: {
  335. 'ticket.priority_id' => {
  336. 'operator' => 'is',
  337. 'value' => [Ticket::Priority.lookup(name: '3 high').id],
  338. }
  339. }, # ticket selector to get only a collection of tickets
  340. )
  341. assert(result)
  342. assert_equal(@ticket5.id, result[:ticket_ids][0])
  343. assert_nil(result[:ticket_ids][1])
  344. # month - with merged tickets selector
  345. result = Report::TicketFirstSolution.aggs(
  346. range_start: '2015-01-01T00:00:00Z',
  347. range_end: '2015-12-31T23:59:59Z',
  348. interval: 'month', # year, quarter, month, week, day, hour, minute, second
  349. selector: {
  350. 'ticket_state.name' => {
  351. 'operator' => 'is not',
  352. 'value' => 'merged',
  353. }
  354. }, # ticket selector to get only a collection of tickets
  355. )
  356. assert(result)
  357. assert_equal(0, result[0])
  358. assert_equal(0, result[1])
  359. assert_equal(0, result[2])
  360. assert_equal(0, result[3])
  361. assert_equal(0, result[4])
  362. assert_equal(0, result[5])
  363. assert_equal(0, result[6])
  364. assert_equal(0, result[7])
  365. assert_equal(0, result[8])
  366. assert_equal(2, result[9])
  367. assert_equal(1, result[10])
  368. assert_equal(0, result[11])
  369. assert_nil(result[12])
  370. result = Report::TicketFirstSolution.items(
  371. range_start: '2015-01-01T00:00:00Z',
  372. range_end: '2015-12-31T23:59:59Z',
  373. selector: {
  374. 'ticket_state.name' => {
  375. 'operator' => 'is not',
  376. 'value' => 'merged',
  377. }
  378. }, # ticket selector to get only a collection of tickets
  379. )
  380. assert(result)
  381. assert_equal(@ticket5.id, result[:ticket_ids][0])
  382. assert_nil(result[:ticket_ids][3])
  383. # month - with selector #2
  384. result = Report::TicketFirstSolution.aggs(
  385. range_start: '2015-01-01T00:00:00Z',
  386. range_end: '2015-12-31T23:59:59Z',
  387. interval: 'month', # year, quarter, month, week, day, hour, minute, second
  388. selector: {
  389. 'ticket.priority_id' => {
  390. 'operator' => 'is not',
  391. 'value' => [Ticket::Priority.lookup(name: '3 high').id],
  392. }
  393. }, # ticket selector to get only a collection of tickets
  394. )
  395. assert(result)
  396. assert_equal(0, result[0])
  397. assert_equal(0, result[1])
  398. assert_equal(0, result[2])
  399. assert_equal(0, result[3])
  400. assert_equal(0, result[4])
  401. assert_equal(0, result[5])
  402. assert_equal(0, result[6])
  403. assert_equal(0, result[7])
  404. assert_equal(0, result[8])
  405. assert_equal(1, result[9])
  406. assert_equal(1, result[10])
  407. assert_equal(0, result[11])
  408. assert_nil(result[12])
  409. result = Report::TicketFirstSolution.items(
  410. range_start: '2015-01-01T00:00:00Z',
  411. range_end: '2015-12-31T23:59:59Z',
  412. selector: {
  413. 'ticket.priority_id' => {
  414. 'operator' => 'is not',
  415. 'value' => [Ticket::Priority.lookup(name: '3 high').id],
  416. }
  417. }, # ticket selector to get only a collection of tickets
  418. )
  419. assert(result)
  420. assert_equal(@ticket6.id, result[:ticket_ids][0])
  421. assert_equal(@ticket7.id, result[:ticket_ids][1])
  422. assert_nil(result[:ticket_ids][2])
  423. # week
  424. result = Report::TicketFirstSolution.aggs(
  425. range_start: '2015-10-26T00:00:00Z',
  426. range_end: '2015-10-31T23:59:59Z',
  427. interval: 'week', # year, quarter, month, week, day, hour, minute, second
  428. selector: {}, # ticket selector to get only a collection of tickets
  429. )
  430. assert(result)
  431. assert_equal(0, result[0])
  432. assert_equal(0, result[1])
  433. assert_equal(1, result[2])
  434. assert_equal(0, result[3])
  435. assert_equal(0, result[4])
  436. assert_equal(1, result[5])
  437. assert_equal(1, result[6])
  438. assert_nil(result[7])
  439. result = Report::TicketFirstSolution.items(
  440. range_start: '2015-10-26T00:00:00Z',
  441. range_end: '2015-11-01T23:59:59Z',
  442. interval: 'week', # year, quarter, month, week, day, hour, minute, second
  443. selector: {}, # ticket selector to get only a collection of tickets
  444. )
  445. assert(result)
  446. assert_equal(@ticket5.id, result[:ticket_ids][0])
  447. assert_equal(@ticket6.id, result[:ticket_ids][1])
  448. assert_equal(@ticket7.id, result[:ticket_ids][2])
  449. assert_nil(result[:ticket_ids][3])
  450. # day
  451. result = Report::TicketFirstSolution.aggs(
  452. range_start: '2015-10-01T00:00:00Z',
  453. range_end: '2015-11-01T23:59:59Z',
  454. interval: 'day', # year, quarter, month, week, day, hour, minute, second
  455. selector: {}, # ticket selector to get only a collection of tickets
  456. )
  457. assert(result)
  458. assert_equal(0, result[0])
  459. assert_equal(0, result[1])
  460. assert_equal(0, result[2])
  461. assert_equal(0, result[3])
  462. assert_equal(0, result[4])
  463. assert_equal(0, result[5])
  464. assert_equal(0, result[6])
  465. assert_equal(0, result[7])
  466. assert_equal(0, result[8])
  467. assert_equal(0, result[9])
  468. assert_equal(0, result[10])
  469. assert_equal(0, result[11])
  470. assert_equal(0, result[12])
  471. assert_equal(0, result[13])
  472. assert_equal(0, result[14])
  473. assert_equal(0, result[15])
  474. assert_equal(0, result[16])
  475. assert_equal(0, result[17])
  476. assert_equal(0, result[18])
  477. assert_equal(0, result[19])
  478. assert_equal(0, result[20])
  479. assert_equal(0, result[21])
  480. assert_equal(0, result[22])
  481. assert_equal(0, result[23])
  482. assert_equal(0, result[24])
  483. assert_equal(0, result[25])
  484. assert_equal(0, result[26])
  485. assert_equal(1, result[27])
  486. assert_equal(0, result[28])
  487. assert_equal(0, result[29])
  488. assert_equal(1, result[30])
  489. assert_nil(result[31])
  490. result = Report::TicketFirstSolution.items(
  491. range_start: '2015-10-01T00:00:00Z',
  492. range_end: '2015-10-31T23:59:59Z',
  493. interval: 'day', # year, quarter, month, week, day, hour, minute, second
  494. selector: {}, # ticket selector to get only a collection of tickets
  495. )
  496. assert(result)
  497. assert_equal(@ticket5.id, result[:ticket_ids][0])
  498. assert_equal(@ticket6.id, result[:ticket_ids][1])
  499. assert_nil(result[:ticket_ids][2])
  500. # hour
  501. result = Report::TicketFirstSolution.aggs(
  502. range_start: '2015-10-28T00:00:00Z',
  503. range_end: '2015-10-28T23:59:59Z',
  504. interval: 'hour', # year, quarter, month, week, day, hour, minute, second
  505. selector: {}, # ticket selector to get only a collection of tickets
  506. )
  507. assert(result)
  508. assert_equal(0, result[0])
  509. assert_equal(0, result[1])
  510. assert_equal(0, result[2])
  511. assert_equal(0, result[3])
  512. assert_equal(0, result[4])
  513. assert_equal(0, result[5])
  514. assert_equal(0, result[6])
  515. assert_equal(0, result[7])
  516. assert_equal(0, result[8])
  517. assert_equal(0, result[9])
  518. assert_equal(0, result[10])
  519. assert_equal(1, result[11])
  520. assert_equal(0, result[12])
  521. assert_equal(0, result[13])
  522. assert_equal(0, result[14])
  523. assert_equal(0, result[15])
  524. assert_equal(0, result[16])
  525. assert_equal(0, result[17])
  526. assert_equal(0, result[18])
  527. assert_equal(0, result[19])
  528. assert_equal(0, result[20])
  529. assert_equal(0, result[21])
  530. assert_equal(0, result[22])
  531. assert_equal(0, result[23])
  532. assert_nil(result[24])
  533. result = Report::TicketFirstSolution.items(
  534. range_start: '2015-10-28T00:00:00Z',
  535. range_end: '2015-10-28T23:59:59Z',
  536. interval: 'hour', # year, quarter, month, week, day, hour, minute, second
  537. selector: {}, # ticket selector to get only a collection of tickets
  538. )
  539. assert(result)
  540. assert_equal(@ticket5.id, result[:ticket_ids][0])
  541. assert_nil(result[:ticket_ids][1])
  542. # reopen
  543. result = Report::TicketReopened.aggs(
  544. range_start: '2015-01-01T00:00:00Z',
  545. range_end: '2015-12-31T23:59:59Z',
  546. interval: 'month', # year, quarter, month, week, day, hour, minute, second
  547. selector: {}, # ticket selector to get only a collection of tickets
  548. )
  549. assert(result)
  550. assert_equal(0, result[0])
  551. assert_equal(0, result[1])
  552. assert_equal(0, result[2])
  553. assert_equal(0, result[3])
  554. assert_equal(0, result[4])
  555. assert_equal(0, result[5])
  556. assert_equal(0, result[6])
  557. assert_equal(0, result[7])
  558. assert_equal(0, result[8])
  559. assert_equal(1, result[9])
  560. assert_equal(0, result[10])
  561. assert_equal(0, result[11])
  562. assert_nil(result[12])
  563. result = Report::TicketReopened.items(
  564. range_start: '2015-01-01T00:00:00Z',
  565. range_end: '2015-12-31T23:59:59Z',
  566. selector: {}, # ticket selector to get only a collection of tickets
  567. )
  568. assert(result)
  569. assert_equal(@ticket5.id, result[:ticket_ids][0])
  570. assert_nil(result[:ticket_ids][1])
  571. # month - with selector #1
  572. result = Report::TicketReopened.aggs(
  573. range_start: '2015-01-01T00:00:00Z',
  574. range_end: '2015-12-31T23:59:59Z',
  575. interval: 'month', # year, quarter, month, week, day, hour, minute, second
  576. selector: {
  577. 'ticket.priority_id' => {
  578. 'operator' => 'is',
  579. 'value' => [Ticket::Priority.lookup(name: '3 high').id],
  580. }
  581. }, # ticket selector to get only a collection of tickets
  582. )
  583. assert(result)
  584. assert_equal(0, result[0])
  585. assert_equal(0, result[1])
  586. assert_equal(0, result[2])
  587. assert_equal(0, result[3])
  588. assert_equal(0, result[4])
  589. assert_equal(0, result[5])
  590. assert_equal(0, result[6])
  591. assert_equal(0, result[7])
  592. assert_equal(0, result[8])
  593. assert_equal(1, result[9])
  594. assert_equal(0, result[10])
  595. assert_equal(0, result[11])
  596. assert_nil(result[12])
  597. result = Report::TicketReopened.items(
  598. range_start: '2015-01-01T00:00:00Z',
  599. range_end: '2015-12-31T23:59:59Z',
  600. selector: {
  601. 'ticket.priority_id' => {
  602. 'operator' => 'is',
  603. 'value' => [Ticket::Priority.lookup(name: '3 high').id],
  604. }
  605. }, # ticket selector to get only a collection of tickets
  606. )
  607. assert(result)
  608. assert_equal(@ticket5.id, result[:ticket_ids][0])
  609. assert_nil(result[:ticket_ids][1])
  610. # month - with selector #2
  611. result = Report::TicketReopened.aggs(
  612. range_start: '2015-01-01T00:00:00Z',
  613. range_end: '2015-12-31T23:59:59Z',
  614. interval: 'month', # year, quarter, month, week, day, hour, minute, second
  615. selector: {
  616. 'ticket.priority_id' => {
  617. 'operator' => 'is not',
  618. 'value' => [Ticket::Priority.lookup(name: '3 high').id],
  619. }
  620. }, # ticket selector to get only a collection of tickets
  621. )
  622. assert(result)
  623. assert_equal(0, result[0])
  624. assert_equal(0, result[1])
  625. assert_equal(0, result[2])
  626. assert_equal(0, result[3])
  627. assert_equal(0, result[4])
  628. assert_equal(0, result[5])
  629. assert_equal(0, result[6])
  630. assert_equal(0, result[7])
  631. assert_equal(0, result[8])
  632. assert_equal(0, result[9])
  633. assert_equal(0, result[10])
  634. assert_equal(0, result[11])
  635. assert_nil(result[12])
  636. result = Report::TicketReopened.items(
  637. range_start: '2015-01-01T00:00:00Z',
  638. range_end: '2015-12-31T23:59:59Z',
  639. selector: {
  640. 'ticket.priority_id' => {
  641. 'operator' => 'is not',
  642. 'value' => [Ticket::Priority.lookup(name: '3 high').id],
  643. }
  644. }, # ticket selector to get only a collection of tickets
  645. )
  646. assert(result)
  647. assert_nil(result[:ticket_ids][0])
  648. # month - reopened with merge selector
  649. result = Report::TicketReopened.aggs(
  650. range_start: '2015-01-01T00:00:00Z',
  651. range_end: '2015-12-31T23:59:59Z',
  652. interval: 'month', # year, quarter, month, week, day, hour, minute, second
  653. selector: {
  654. 'ticket_state.name' => {
  655. 'operator' => 'is not',
  656. 'value' => 'merged',
  657. }
  658. }, # ticket selector to get only a collection of tickets
  659. )
  660. assert(result)
  661. assert_equal(0, result[0])
  662. assert_equal(0, result[1])
  663. assert_equal(0, result[2])
  664. assert_equal(0, result[3])
  665. assert_equal(0, result[4])
  666. assert_equal(0, result[5])
  667. assert_equal(0, result[6])
  668. assert_equal(0, result[7])
  669. assert_equal(0, result[8])
  670. assert_equal(1, result[9])
  671. assert_equal(0, result[10])
  672. assert_equal(0, result[11])
  673. assert_nil(result[12])
  674. result = Report::TicketReopened.items(
  675. range_start: '2015-01-01T00:00:00Z',
  676. range_end: '2015-12-31T23:59:59Z',
  677. selector: {
  678. 'ticket_state.name' => {
  679. 'operator' => 'is not',
  680. 'value' => 'merged',
  681. }
  682. }, # ticket selector to get only a collection of tickets
  683. )
  684. assert(result)
  685. assert_equal(@ticket5.id, result[:ticket_ids][0])
  686. assert_nil(result[:ticket_ids][1])
  687. # move in/out without merged status
  688. result = Report::TicketMoved.aggs(
  689. range_start: '2015-01-01T00:00:00Z',
  690. range_end: '2015-12-31T23:59:59Z',
  691. interval: 'month', # year, quarter, month, week, day, hour, minute, second
  692. selector: {
  693. 'ticket_state.name' => {
  694. 'operator' => 'is not',
  695. 'value' => 'merged',
  696. }
  697. }, # ticket selector to get only a collection of tickets
  698. params: {
  699. type: 'in',
  700. },
  701. )
  702. assert(result)
  703. assert_equal(0, result[0])
  704. assert_equal(0, result[1])
  705. assert_equal(0, result[2])
  706. assert_equal(0, result[3])
  707. assert_equal(0, result[4])
  708. assert_equal(0, result[5])
  709. assert_equal(0, result[6])
  710. assert_equal(0, result[7])
  711. assert_equal(0, result[8])
  712. assert_equal(0, result[9])
  713. assert_equal(0, result[10])
  714. assert_equal(0, result[11])
  715. assert_nil(result[12])
  716. result = Report::TicketMoved.items(
  717. range_start: '2015-01-01T00:00:00Z',
  718. range_end: '2015-12-31T23:59:59Z',
  719. selector: {
  720. 'ticket.group_id' => {
  721. 'operator' => 'is',
  722. 'value' => [Group.lookup(name: 'Users').id],
  723. }
  724. }, # ticket selector to get only a collection of tickets
  725. params: {
  726. type: 'in',
  727. },
  728. )
  729. assert(result)
  730. assert_equal(@ticket1.id, result[:ticket_ids][0])
  731. assert_nil(result[:ticket_ids][1])
  732. # move in/out
  733. result = Report::TicketMoved.aggs(
  734. range_start: '2015-01-01T00:00:00Z',
  735. range_end: '2015-12-31T23:59:59Z',
  736. interval: 'month', # year, quarter, month, week, day, hour, minute, second
  737. selector: {
  738. 'ticket.group_id' => {
  739. 'operator' => 'is',
  740. 'value' => [Group.lookup(name: 'Users').id],
  741. }
  742. }, # ticket selector to get only a collection of tickets
  743. params: {
  744. type: 'in',
  745. },
  746. )
  747. assert(result)
  748. assert_equal(0, result[0])
  749. assert_equal(0, result[1])
  750. assert_equal(0, result[2])
  751. assert_equal(0, result[3])
  752. assert_equal(0, result[4])
  753. assert_equal(0, result[5])
  754. assert_equal(0, result[6])
  755. assert_equal(0, result[7])
  756. assert_equal(0, result[8])
  757. assert_equal(1, result[9])
  758. assert_equal(0, result[10])
  759. assert_equal(0, result[11])
  760. assert_nil(result[12])
  761. result = Report::TicketMoved.items(
  762. range_start: '2015-01-01T00:00:00Z',
  763. range_end: '2015-12-31T23:59:59Z',
  764. selector: {
  765. 'ticket.group_id' => {
  766. 'operator' => 'is',
  767. 'value' => [Group.lookup(name: 'Users').id],
  768. }
  769. }, # ticket selector to get only a collection of tickets
  770. params: {
  771. type: 'in',
  772. },
  773. )
  774. assert(result)
  775. assert_equal(@ticket1.id, result[:ticket_ids][0])
  776. assert_nil(result[:ticket_ids][1])
  777. # out without merged tickets
  778. result = Report::TicketMoved.aggs(
  779. range_start: '2015-01-01T00:00:00Z',
  780. range_end: '2015-12-31T23:59:59Z',
  781. interval: 'month', # year, quarter, month, week, day, hour, minute, second
  782. selector: {
  783. 'ticket_state.name' => {
  784. 'operator' => 'is not',
  785. 'value' => 'merged',
  786. }
  787. }, # ticket selector to get only a collection of tickets
  788. params: {
  789. type: 'out',
  790. },
  791. )
  792. assert(result)
  793. assert_equal(0, result[0])
  794. assert_equal(0, result[1])
  795. assert_equal(0, result[2])
  796. assert_equal(0, result[3])
  797. assert_equal(0, result[4])
  798. assert_equal(0, result[5])
  799. assert_equal(0, result[6])
  800. assert_equal(0, result[7])
  801. assert_equal(0, result[8])
  802. assert_equal(0, result[9])
  803. assert_equal(0, result[10])
  804. assert_equal(0, result[11])
  805. assert_nil(result[12])
  806. result = Report::TicketMoved.items(
  807. range_start: '2015-01-01T00:00:00Z',
  808. range_end: '2015-12-31T23:59:59Z',
  809. selector: {
  810. 'ticket_state.name' => {
  811. 'operator' => 'is not',
  812. 'value' => 'merged',
  813. }
  814. }, # ticket selector to get only a collection of tickets
  815. params: {
  816. type: 'out',
  817. },
  818. )
  819. assert(result)
  820. assert_nil(result[:ticket_ids][0])
  821. # out
  822. result = Report::TicketMoved.aggs(
  823. range_start: '2015-01-01T00:00:00Z',
  824. range_end: '2015-12-31T23:59:59Z',
  825. interval: 'month', # year, quarter, month, week, day, hour, minute, second
  826. selector: {
  827. 'ticket.group_id' => {
  828. 'operator' => 'is',
  829. 'value' => [Group.lookup(name: 'Users').id],
  830. }
  831. }, # ticket selector to get only a collection of tickets
  832. params: {
  833. type: 'out',
  834. },
  835. )
  836. assert(result)
  837. assert_equal(0, result[0])
  838. assert_equal(0, result[1])
  839. assert_equal(0, result[2])
  840. assert_equal(0, result[3])
  841. assert_equal(0, result[4])
  842. assert_equal(0, result[5])
  843. assert_equal(0, result[6])
  844. assert_equal(0, result[7])
  845. assert_equal(0, result[8])
  846. assert_equal(1, result[9])
  847. assert_equal(0, result[10])
  848. assert_equal(0, result[11])
  849. assert_nil(result[12])
  850. result = Report::TicketMoved.items(
  851. range_start: '2015-01-01T00:00:00Z',
  852. range_end: '2015-12-31T23:59:59Z',
  853. selector: {
  854. 'ticket.group_id' => {
  855. 'operator' => 'is',
  856. 'value' => [Group.lookup(name: 'Users').id],
  857. }
  858. }, # ticket selector to get only a collection of tickets
  859. params: {
  860. type: 'out',
  861. },
  862. )
  863. assert(result)
  864. assert_equal(@ticket2.id, result[:ticket_ids][0])
  865. assert_nil(result[:ticket_ids][1])
  866. # create at
  867. result = Report::TicketGenericTime.aggs(
  868. range_start: '2015-01-01T00:00:00Z',
  869. range_end: '2015-12-31T23:59:59Z',
  870. interval: 'month', # year, quarter, month, week, day, hour, minute, second
  871. selector: {}, # ticket selector to get only a collection of tickets
  872. params: { field: 'created_at' },
  873. )
  874. assert(result)
  875. assert_equal(0, result[0])
  876. assert_equal(0, result[1])
  877. assert_equal(0, result[2])
  878. assert_equal(0, result[3])
  879. assert_equal(0, result[4])
  880. assert_equal(0, result[5])
  881. assert_equal(0, result[6])
  882. assert_equal(0, result[7])
  883. assert_equal(0, result[8])
  884. assert_equal(6, result[9])
  885. assert_equal(1, result[10])
  886. assert_equal(0, result[11])
  887. assert_nil(result[12])
  888. result = Report::TicketGenericTime.items(
  889. range_start: '2015-01-01T00:00:00Z',
  890. range_end: '2015-12-31T23:59:59Z',
  891. selector: {}, # ticket selector to get only a collection of tickets
  892. params: { field: 'created_at' },
  893. )
  894. assert(result)
  895. assert_equal(@ticket7.id, result[:ticket_ids][0].to_i)
  896. assert_equal(@ticket6.id, result[:ticket_ids][1].to_i)
  897. assert_equal(@ticket5.id, result[:ticket_ids][2].to_i)
  898. assert_equal(@ticket4.id, result[:ticket_ids][3].to_i)
  899. assert_equal(@ticket3.id, result[:ticket_ids][4].to_i)
  900. assert_equal(@ticket2.id, result[:ticket_ids][5].to_i)
  901. assert_equal(@ticket1.id, result[:ticket_ids][6].to_i)
  902. assert_nil(result[:ticket_ids][7])
  903. # create at - selector with merge
  904. result = Report::TicketGenericTime.aggs(
  905. range_start: '2015-01-01T00:00:00Z',
  906. range_end: '2015-12-31T23:59:59Z',
  907. interval: 'month', # year, quarter, month, week, day, hour, minute, second
  908. selector: {
  909. 'state' => {
  910. 'operator' => 'is not',
  911. 'value' => 'merged'
  912. }
  913. }, # ticket selector to get only a collection of tickets
  914. params: { field: 'created_at' },
  915. )
  916. assert(result)
  917. assert_equal(0, result[0])
  918. assert_equal(0, result[1])
  919. assert_equal(0, result[2])
  920. assert_equal(0, result[3])
  921. assert_equal(0, result[4])
  922. assert_equal(0, result[5])
  923. assert_equal(0, result[6])
  924. assert_equal(0, result[7])
  925. assert_equal(0, result[8])
  926. assert_equal(6, result[9])
  927. assert_equal(1, result[10])
  928. assert_equal(0, result[11])
  929. assert_nil(result[12])
  930. result = Report::TicketGenericTime.items(
  931. range_start: '2015-01-01T00:00:00Z',
  932. range_end: '2015-12-31T23:59:59Z',
  933. selector: {
  934. 'state' => {
  935. 'operator' => 'is not',
  936. 'value' => 'merged'
  937. }
  938. }, # ticket selector to get only a collection of tickets
  939. params: { field: 'created_at' },
  940. )
  941. assert(result)
  942. assert_equal(@ticket7.id, result[:ticket_ids][0].to_i)
  943. assert_equal(@ticket6.id, result[:ticket_ids][1].to_i)
  944. assert_equal(@ticket5.id, result[:ticket_ids][2].to_i)
  945. assert_equal(@ticket4.id, result[:ticket_ids][3].to_i)
  946. assert_equal(@ticket3.id, result[:ticket_ids][4].to_i)
  947. assert_equal(@ticket2.id, result[:ticket_ids][5].to_i)
  948. assert_equal(@ticket1.id, result[:ticket_ids][6].to_i)
  949. assert_nil(result[:ticket_ids][7])
  950. result = Report::TicketGenericTime.items(
  951. range_start: '2015-01-01T00:00:00Z',
  952. range_end: '2015-12-31T23:59:59Z',
  953. selector: {
  954. 'created_at' => {
  955. 'operator' => 'before (absolute)',
  956. 'value' => '2015-10-31T00:00:00Z'
  957. }
  958. }, # ticket selector to get only a collection of tickets
  959. params: { field: 'created_at' },
  960. )
  961. assert(result)
  962. assert_equal(@ticket5.id, result[:ticket_ids][0].to_i)
  963. assert_equal(@ticket4.id, result[:ticket_ids][1].to_i)
  964. assert_equal(@ticket3.id, result[:ticket_ids][2].to_i)
  965. assert_equal(@ticket2.id, result[:ticket_ids][3].to_i)
  966. assert_equal(@ticket1.id, result[:ticket_ids][4].to_i)
  967. assert_nil(result[:ticket_ids][5])
  968. result = Report::TicketGenericTime.items(
  969. range_start: '2015-01-01T00:00:00Z',
  970. range_end: '2015-12-31T23:59:59Z',
  971. selector: {
  972. 'created_at' => {
  973. 'operator' => 'after (absolute)',
  974. 'value' => '2015-10-31T00:00:00Z'
  975. }
  976. }, # ticket selector to get only a collection of tickets
  977. params: { field: 'created_at' },
  978. )
  979. assert(result)
  980. assert_equal(@ticket7.id, result[:ticket_ids][0].to_i)
  981. assert_equal(@ticket6.id, result[:ticket_ids][1].to_i)
  982. assert_nil(result[:ticket_ids][2])
  983. result = Report::TicketGenericTime.items(
  984. range_start: '2015-01-01T00:00:00Z',
  985. range_end: '2015-12-31T23:59:59Z',
  986. selector: {
  987. 'created_at' => {
  988. 'operator' => 'before (relative)',
  989. 'range' => 'day',
  990. 'value' => '1'
  991. }
  992. }, # ticket selector to get only a collection of tickets
  993. params: { field: 'created_at' },
  994. )
  995. result = Report::TicketGenericTime.items(
  996. range_start: '2015-01-01T00:00:00Z',
  997. range_end: '2015-12-31T23:59:59Z',
  998. selector: {
  999. 'created_at' => {
  1000. 'operator' => 'after (relative)',
  1001. 'range' => 'day',
  1002. 'value' => '1'
  1003. }
  1004. }, # ticket selector to get only a collection of tickets
  1005. params: { field: 'created_at' },
  1006. )
  1007. assert(result)
  1008. assert_nil(result[:ticket_ids][0])
  1009. result = Report::TicketGenericTime.items(
  1010. range_start: '2037-01-01T00:00:00Z',
  1011. range_end: '2037-12-31T23:59:59Z',
  1012. selector: {
  1013. 'created_at' => {
  1014. 'operator' => 'before (relative)',
  1015. 'range' => 'day',
  1016. 'value' => '1'
  1017. }
  1018. }, # ticket selector to get only a collection of tickets
  1019. params: { field: 'created_at' },
  1020. )
  1021. assert(result)
  1022. assert_nil(result[:ticket_ids][0])
  1023. result = Report::TicketGenericTime.items(
  1024. range_start: '2037-01-01T00:00:00Z',
  1025. range_end: '2037-12-31T23:59:59Z',
  1026. selector: {
  1027. 'created_at' => {
  1028. 'operator' => 'after (relative)',
  1029. 'range' => 'day',
  1030. 'value' => '5'
  1031. }
  1032. }, # ticket selector to get only a collection of tickets
  1033. params: { field: 'created_at' },
  1034. )
  1035. assert(result)
  1036. assert_equal(@ticket9.id, result[:ticket_ids][0].to_i)
  1037. assert_nil(result[:ticket_ids][1])
  1038. result = Report::TicketGenericTime.items(
  1039. range_start: '2037-01-01T00:00:00Z',
  1040. range_end: '2037-12-31T23:59:59Z',
  1041. selector: {
  1042. 'created_at' => {
  1043. 'operator' => 'before (relative)',
  1044. 'range' => 'month',
  1045. 'value' => '1'
  1046. }
  1047. }, # ticket selector to get only a collection of tickets
  1048. params: { field: 'created_at' },
  1049. )
  1050. assert(result)
  1051. assert_nil(result[:ticket_ids][0])
  1052. result = Report::TicketGenericTime.items(
  1053. range_start: '2037-01-01T00:00:00Z',
  1054. range_end: '2037-12-31T23:59:59Z',
  1055. selector: {
  1056. 'created_at' => {
  1057. 'operator' => 'after (relative)',
  1058. 'range' => 'month',
  1059. 'value' => '5'
  1060. }
  1061. }, # ticket selector to get only a collection of tickets
  1062. params: { field: 'created_at' },
  1063. )
  1064. assert(result)
  1065. assert_equal(@ticket9.id, result[:ticket_ids][0].to_i)
  1066. assert_nil(result[:ticket_ids][1])
  1067. result = Report::TicketGenericTime.items(
  1068. range_start: '2037-01-01T00:00:00Z',
  1069. range_end: '2037-12-31T23:59:59Z',
  1070. selector: {
  1071. 'created_at' => {
  1072. 'operator' => 'before (relative)',
  1073. 'range' => 'year',
  1074. 'value' => '1'
  1075. }
  1076. }, # ticket selector to get only a collection of tickets
  1077. params: { field: 'created_at' },
  1078. )
  1079. assert(result)
  1080. assert_nil(result[:ticket_ids][0])
  1081. result = Report::TicketGenericTime.items(
  1082. range_start: '2037-01-01T00:00:00Z',
  1083. range_end: '2037-12-31T23:59:59Z',
  1084. selector: {
  1085. 'created_at' => {
  1086. 'operator' => 'after (relative)',
  1087. 'range' => 'year',
  1088. 'value' => '5'
  1089. }
  1090. }, # ticket selector to get only a collection of tickets
  1091. params: { field: 'created_at' },
  1092. )
  1093. assert(result)
  1094. assert_equal(@ticket9.id, result[:ticket_ids][0].to_i)
  1095. assert_nil(result[:ticket_ids][1])
  1096. result = Report::TicketGenericTime.items(
  1097. range_start: '2015-01-01T00:00:00Z',
  1098. range_end: '2015-12-31T23:59:59Z',
  1099. selector: {
  1100. 'tags' => {
  1101. 'operator' => 'contains all',
  1102. 'value' => 'aaa, bbb'
  1103. }
  1104. }, # ticket selector to get only a collection of tickets
  1105. params: { field: 'created_at' },
  1106. )
  1107. assert(result)
  1108. assert_equal(@ticket1.id, result[:ticket_ids][0].to_i)
  1109. assert_nil(result[:ticket_ids][1])
  1110. result = Report::TicketGenericTime.items(
  1111. range_start: '2015-01-01T00:00:00Z',
  1112. range_end: '2015-12-31T23:59:59Z',
  1113. selector: {
  1114. 'tags' => {
  1115. 'operator' => 'contains all not',
  1116. 'value' => 'aaa, bbb'
  1117. }
  1118. }, # ticket selector to get only a collection of tickets
  1119. params: { field: 'created_at' },
  1120. )
  1121. assert(result)
  1122. assert_equal(@ticket7.id, result[:ticket_ids][0].to_i)
  1123. assert_equal(@ticket6.id, result[:ticket_ids][1].to_i)
  1124. assert_equal(@ticket5.id, result[:ticket_ids][2].to_i)
  1125. assert_equal(@ticket4.id, result[:ticket_ids][3].to_i)
  1126. assert_equal(@ticket3.id, result[:ticket_ids][4].to_i)
  1127. assert_equal(@ticket2.id, result[:ticket_ids][5].to_i)
  1128. assert_nil(result[:ticket_ids][6])
  1129. result = Report::TicketGenericTime.items(
  1130. range_start: '2015-01-01T00:00:00Z',
  1131. range_end: '2015-12-31T23:59:59Z',
  1132. selector: {
  1133. 'tags' => {
  1134. 'operator' => 'contains all',
  1135. 'value' => 'aaa'
  1136. }
  1137. }, # ticket selector to get only a collection of tickets
  1138. params: { field: 'created_at' },
  1139. )
  1140. assert(result)
  1141. assert_equal(@ticket2.id, result[:ticket_ids][0].to_i)
  1142. assert_equal(@ticket1.id, result[:ticket_ids][1].to_i)
  1143. assert_nil(result[:ticket_ids][2])
  1144. result = Report::TicketGenericTime.items(
  1145. range_start: '2015-01-01T00:00:00Z',
  1146. range_end: '2015-12-31T23:59:59Z',
  1147. selector: {
  1148. 'tags' => {
  1149. 'operator' => 'contains all not',
  1150. 'value' => 'aaa'
  1151. }
  1152. }, # ticket selector to get only a collection of tickets
  1153. params: { field: 'created_at' },
  1154. )
  1155. assert(result)
  1156. assert_equal(@ticket7.id, result[:ticket_ids][0].to_i)
  1157. assert_equal(@ticket6.id, result[:ticket_ids][1].to_i)
  1158. assert_equal(@ticket5.id, result[:ticket_ids][2].to_i)
  1159. assert_equal(@ticket4.id, result[:ticket_ids][3].to_i)
  1160. assert_equal(@ticket3.id, result[:ticket_ids][4].to_i)
  1161. assert_nil(result[:ticket_ids][5])
  1162. result = Report::TicketGenericTime.items(
  1163. range_start: '2015-01-01T00:00:00Z',
  1164. range_end: '2015-12-31T23:59:59Z',
  1165. selector: {
  1166. 'tags' => {
  1167. 'operator' => 'contains one not',
  1168. 'value' => 'aaa'
  1169. }
  1170. }, # ticket selector to get only a collection of tickets
  1171. params: { field: 'created_at' },
  1172. )
  1173. assert(result)
  1174. assert_equal(@ticket7.id, result[:ticket_ids][0].to_i)
  1175. assert_equal(@ticket6.id, result[:ticket_ids][1].to_i)
  1176. assert_equal(@ticket5.id, result[:ticket_ids][2].to_i)
  1177. assert_equal(@ticket4.id, result[:ticket_ids][3].to_i)
  1178. assert_equal(@ticket3.id, result[:ticket_ids][4].to_i)
  1179. assert_nil(result[:ticket_ids][5])
  1180. result = Report::TicketGenericTime.items(
  1181. range_start: '2015-01-01T00:00:00Z',
  1182. range_end: '2015-12-31T23:59:59Z',
  1183. selector: {
  1184. 'tags' => {
  1185. 'operator' => 'contains one not',
  1186. 'value' => 'aaa, bbb'
  1187. }
  1188. }, # ticket selector to get only a collection of tickets
  1189. params: { field: 'created_at' },
  1190. )
  1191. assert(result)
  1192. assert_equal(@ticket7.id, result[:ticket_ids][0].to_i)
  1193. assert_equal(@ticket6.id, result[:ticket_ids][1].to_i)
  1194. assert_equal(@ticket4.id, result[:ticket_ids][2].to_i)
  1195. assert_equal(@ticket3.id, result[:ticket_ids][3].to_i)
  1196. assert_nil(result[:ticket_ids][4])
  1197. result = Report::TicketGenericTime.items(
  1198. range_start: '2015-01-01T00:00:00Z',
  1199. range_end: '2015-12-31T23:59:59Z',
  1200. selector: {
  1201. 'tags' => {
  1202. 'operator' => 'contains one',
  1203. 'value' => 'aaa'
  1204. }
  1205. }, # ticket selector to get only a collection of tickets
  1206. params: { field: 'created_at' },
  1207. )
  1208. assert(result)
  1209. assert_equal(@ticket2.id, result[:ticket_ids][0].to_i)
  1210. assert_equal(@ticket1.id, result[:ticket_ids][1].to_i)
  1211. assert_nil(result[:ticket_ids][2])
  1212. result = Report::TicketGenericTime.items(
  1213. range_start: '2015-01-01T00:00:00Z',
  1214. range_end: '2015-12-31T23:59:59Z',
  1215. selector: {
  1216. 'tags' => {
  1217. 'operator' => 'contains one',
  1218. 'value' => 'aaa, bbb'
  1219. }
  1220. }, # ticket selector to get only a collection of tickets
  1221. params: { field: 'created_at' },
  1222. )
  1223. assert(result)
  1224. assert_equal(@ticket5.id, result[:ticket_ids][0].to_i)
  1225. assert_equal(@ticket2.id, result[:ticket_ids][1].to_i)
  1226. assert_equal(@ticket1.id, result[:ticket_ids][2].to_i)
  1227. assert_nil(result[:ticket_ids][3])
  1228. result = Report::TicketGenericTime.items(
  1229. range_start: '2015-01-01T00:00:00Z',
  1230. range_end: '2015-12-31T23:59:59Z',
  1231. selector: {
  1232. 'title' => {
  1233. 'operator' => 'contains',
  1234. 'value' => 'test'
  1235. }
  1236. }, # ticket selector to get only a collection of tickets
  1237. params: { field: 'created_at' },
  1238. )
  1239. assert(result)
  1240. assert_equal(@ticket7.id, result[:ticket_ids][0].to_i)
  1241. assert_equal(@ticket6.id, result[:ticket_ids][1].to_i)
  1242. assert_equal(@ticket5.id, result[:ticket_ids][2].to_i)
  1243. assert_equal(@ticket4.id, result[:ticket_ids][3].to_i)
  1244. assert_equal(@ticket3.id, result[:ticket_ids][4].to_i)
  1245. assert_equal(@ticket2.id, result[:ticket_ids][5].to_i)
  1246. assert_equal(@ticket1.id, result[:ticket_ids][6].to_i)
  1247. assert_nil(result[:ticket_ids][7])
  1248. result = Report::TicketGenericTime.items(
  1249. range_start: '2015-01-01T00:00:00Z',
  1250. range_end: '2015-12-31T23:59:59Z',
  1251. selector: {
  1252. 'title' => {
  1253. 'operator' => 'contains not',
  1254. 'value' => 'test'
  1255. }
  1256. }, # ticket selector to get only a collection of tickets
  1257. params: { field: 'created_at' },
  1258. )
  1259. assert(result)
  1260. assert_nil(result[:ticket_ids][0])
  1261. end
  1262. end