projectStatsToSeries.spec.tsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. import {projectStatsToSeries} from 'sentry/views/settings/project/server-side-sampling/utils/projectStatsToSeries';
  2. import {outcomesWithoutClientDiscarded} from '../testUtils';
  3. describe('projectStatsToSeries', function () {
  4. it('returns correct series', function () {
  5. expect(projectStatsToSeries(TestStubs.OutcomesWithReason())).toEqual([
  6. {
  7. seriesName: 'Indexed and Processed',
  8. color: '#2BA185',
  9. barMinHeight: 0,
  10. type: 'bar',
  11. stack: 'usage',
  12. data: [
  13. {name: 1656788400000, value: 294117},
  14. {name: 1656792000000, value: 281850},
  15. {name: 1656795600000, value: 263003},
  16. {name: 1656799200000, value: 259581},
  17. {name: 1656802800000, value: 246831},
  18. {name: 1656806400000, value: 278464},
  19. {name: 1656810000000, value: 290677},
  20. {name: 1656813600000, value: 242770},
  21. {name: 1656817200000, value: 242559},
  22. {name: 1656820800000, value: 248963},
  23. {name: 1656824400000, value: 250920},
  24. {name: 1656828000000, value: 268994},
  25. {name: 1656831600000, value: 296129},
  26. {name: 1656835200000, value: 308165},
  27. {name: 1656838800000, value: 302398},
  28. {name: 1656842400000, value: 301891},
  29. {name: 1656846000000, value: 316698},
  30. {name: 1656849600000, value: 333888},
  31. {name: 1656853200000, value: 336204},
  32. {name: 1656856800000, value: 329735},
  33. {name: 1656860400000, value: 323717},
  34. {name: 1656864000000, value: 317564},
  35. {name: 1656867600000, value: 312407},
  36. {name: 1656871200000, value: 307008},
  37. {name: 1656874800000, value: 301681},
  38. {name: 1656878400000, value: 299652},
  39. {name: 1656882000000, value: 276849},
  40. {name: 1656885600000, value: 274486},
  41. {name: 1656889200000, value: 298985},
  42. {name: 1656892800000, value: 368148},
  43. {name: 1656896400000, value: 444434},
  44. {name: 1656900000000, value: 423119},
  45. {name: 1656903600000, value: 416110},
  46. {name: 1656907200000, value: 464443},
  47. {name: 1656910800000, value: 526387},
  48. {name: 1656914400000, value: 692300},
  49. {name: 1656918000000, value: 720026},
  50. {name: 1656921600000, value: 719854},
  51. {name: 1656925200000, value: 719658},
  52. {name: 1656928800000, value: 719237},
  53. {name: 1656932400000, value: 717889},
  54. {name: 1656936000000, value: 719757},
  55. {name: 1656939600000, value: 718147},
  56. {name: 1656943200000, value: 719843},
  57. {name: 1656946800000, value: 712099},
  58. {name: 1656950400000, value: 643028},
  59. {name: 1656954000000, value: 545065},
  60. {name: 1656957600000, value: 311310},
  61. ],
  62. },
  63. {
  64. seriesName: 'Processed',
  65. color: '#F5B000',
  66. data: [
  67. {name: 1656788400000, value: 248},
  68. {name: 1656792000000, value: 278},
  69. {name: 1656795600000, value: 244},
  70. {name: 1656799200000, value: 241},
  71. {name: 1656802800000, value: 270},
  72. {name: 1656806400000, value: 269},
  73. {name: 1656810000000, value: 285},
  74. {name: 1656813600000, value: 256},
  75. {name: 1656817200000, value: 248},
  76. {name: 1656820800000, value: 267},
  77. {name: 1656824400000, value: 326},
  78. {name: 1656828000000, value: 335},
  79. {name: 1656831600000, value: 258},
  80. {name: 1656835200000, value: 255},
  81. {name: 1656838800000, value: 269},
  82. {name: 1656842400000, value: 292},
  83. {name: 1656846000000, value: 271},
  84. {name: 1656849600000, value: 246},
  85. {name: 1656853200000, value: 254},
  86. {name: 1656856800000, value: 285},
  87. {name: 1656860400000, value: 291},
  88. {name: 1656864000000, value: 295},
  89. {name: 1656867600000, value: 260},
  90. {name: 1656871200000, value: 292},
  91. {name: 1656874800000, value: 242},
  92. {name: 1656878400000, value: 318},
  93. {name: 1656882000000, value: 326},
  94. {name: 1656885600000, value: 302},
  95. {name: 1656889200000, value: 299},
  96. {name: 1656892800000, value: 299},
  97. {name: 1656896400000, value: 321},
  98. {name: 1656900000000, value: 310},
  99. {name: 1656903600000, value: 320},
  100. {name: 1656907200000, value: 371},
  101. {name: 1656910800000, value: 323},
  102. {name: 1656914400000, value: 331},
  103. {name: 1656918000000, value: 286},
  104. {name: 1656921600000, value: 256},
  105. {name: 1656925200000, value: 275},
  106. {name: 1656928800000, value: 316},
  107. {name: 1656932400000, value: 294},
  108. {name: 1656936000000, value: 295},
  109. {name: 1656939600000, value: 301},
  110. {name: 1656943200000, value: 282},
  111. {name: 1656946800000, value: 391},
  112. {name: 1656950400000, value: 358},
  113. {name: 1656954000000, value: 391},
  114. {name: 1656957600000, value: 217},
  115. ],
  116. barMinHeight: 0,
  117. type: 'bar',
  118. stack: 'usage',
  119. },
  120. {
  121. seriesName: 'Discarded',
  122. color: '#F55459',
  123. data: [
  124. {name: 1656788400000, value: 0},
  125. {name: 1656792000000, value: 1},
  126. {name: 1656795600000, value: 1},
  127. {name: 1656799200000, value: 1},
  128. {name: 1656802800000, value: 94},
  129. {name: 1656806400000, value: 1},
  130. {name: 1656810000000, value: 1},
  131. {name: 1656813600000, value: 0},
  132. {name: 1656817200000, value: 566},
  133. {name: 1656820800000, value: 179},
  134. {name: 1656824400000, value: 1},
  135. {name: 1656828000000, value: 1},
  136. {name: 1656831600000, value: 1},
  137. {name: 1656835200000, value: 0},
  138. {name: 1656838800000, value: 222},
  139. {name: 1656842400000, value: 6},
  140. {name: 1656846000000, value: 287},
  141. {name: 1656849600000, value: 465},
  142. {name: 1656853200000, value: 83},
  143. {name: 1656856800000, value: 7},
  144. {name: 1656860400000, value: 0},
  145. {name: 1656864000000, value: 1835},
  146. {name: 1656867600000, value: 145},
  147. {name: 1656871200000, value: 0},
  148. {name: 1656874800000, value: 0},
  149. {name: 1656878400000, value: 1},
  150. {name: 1656882000000, value: 0},
  151. {name: 1656885600000, value: 0},
  152. {name: 1656889200000, value: 0},
  153. {name: 1656892800000, value: 1},
  154. {name: 1656896400000, value: 0},
  155. {name: 1656900000000, value: 2},
  156. {name: 1656903600000, value: 0},
  157. {name: 1656907200000, value: 1},
  158. {name: 1656910800000, value: 849},
  159. {name: 1656914400000, value: 25331},
  160. {name: 1656918000000, value: 147200},
  161. {name: 1656921600000, value: 220014},
  162. {name: 1656925200000, value: 189001},
  163. {name: 1656928800000, value: 99590},
  164. {name: 1656932400000, value: 81288},
  165. {name: 1656936000000, value: 134522},
  166. {name: 1656939600000, value: 151489},
  167. {name: 1656943200000, value: 128585},
  168. {name: 1656946800000, value: 41643},
  169. {name: 1656950400000, value: 6404},
  170. {name: 1656954000000, value: 145},
  171. {name: 1656957600000, value: 1381},
  172. ],
  173. barMinHeight: 0,
  174. type: 'bar',
  175. stack: 'usage',
  176. },
  177. ]);
  178. });
  179. it('handles outcomes without client reports', function () {
  180. expect(projectStatsToSeries(outcomesWithoutClientDiscarded, 0.2)).toEqual([
  181. {
  182. seriesName: 'Indexed and Processed',
  183. color: '#2BA185',
  184. barMinHeight: 0,
  185. type: 'bar',
  186. stack: 'usage',
  187. data: [
  188. {name: 1656788400000, value: 294117},
  189. {name: 1656792000000, value: 281850},
  190. {name: 1656795600000, value: 263003},
  191. {name: 1656799200000, value: 259581},
  192. {name: 1656802800000, value: 246831},
  193. {name: 1656806400000, value: 278464},
  194. {name: 1656810000000, value: 290677},
  195. {name: 1656813600000, value: 242770},
  196. {name: 1656817200000, value: 242559},
  197. {name: 1656820800000, value: 248963},
  198. {name: 1656824400000, value: 250920},
  199. {name: 1656828000000, value: 268994},
  200. {name: 1656831600000, value: 296129},
  201. {name: 1656835200000, value: 308165},
  202. {name: 1656838800000, value: 302398},
  203. {name: 1656842400000, value: 301891},
  204. {name: 1656846000000, value: 316698},
  205. {name: 1656849600000, value: 333888},
  206. {name: 1656853200000, value: 336204},
  207. {name: 1656856800000, value: 329735},
  208. {name: 1656860400000, value: 323717},
  209. {name: 1656864000000, value: 317564},
  210. {name: 1656867600000, value: 312407},
  211. {name: 1656871200000, value: 307008},
  212. {name: 1656874800000, value: 301681},
  213. {name: 1656878400000, value: 299652},
  214. {name: 1656882000000, value: 276849},
  215. {name: 1656885600000, value: 274486},
  216. {name: 1656889200000, value: 298985},
  217. {name: 1656892800000, value: 368148},
  218. {name: 1656896400000, value: 444434},
  219. {name: 1656900000000, value: 423119},
  220. {name: 1656903600000, value: 416110},
  221. {name: 1656907200000, value: 464443},
  222. {name: 1656910800000, value: 526387},
  223. {name: 1656914400000, value: 692300},
  224. {name: 1656918000000, value: 720026},
  225. {name: 1656921600000, value: 719854},
  226. {name: 1656925200000, value: 719658},
  227. {name: 1656928800000, value: 719237},
  228. {name: 1656932400000, value: 717889},
  229. {name: 1656936000000, value: 719757},
  230. {name: 1656939600000, value: 718147},
  231. {name: 1656943200000, value: 719843},
  232. {name: 1656946800000, value: 712099},
  233. {name: 1656950400000, value: 643028},
  234. {name: 1656954000000, value: 545065},
  235. {name: 1656957600000, value: 311310},
  236. ],
  237. },
  238. {
  239. seriesName: 'Processed',
  240. color: '#F5B000',
  241. data: [
  242. {name: 1656788400000, value: 248},
  243. {name: 1656792000000, value: 278},
  244. {name: 1656795600000, value: 244},
  245. {name: 1656799200000, value: 241},
  246. {name: 1656802800000, value: 270},
  247. {name: 1656806400000, value: 269},
  248. {name: 1656810000000, value: 285},
  249. {name: 1656813600000, value: 256},
  250. {name: 1656817200000, value: 248},
  251. {name: 1656820800000, value: 267},
  252. {name: 1656824400000, value: 326},
  253. {name: 1656828000000, value: 335},
  254. {name: 1656831600000, value: 258},
  255. {name: 1656835200000, value: 255},
  256. {name: 1656838800000, value: 269},
  257. {name: 1656842400000, value: 292},
  258. {name: 1656846000000, value: 271},
  259. {name: 1656849600000, value: 246},
  260. {name: 1656853200000, value: 254},
  261. {name: 1656856800000, value: 285},
  262. {name: 1656860400000, value: 291},
  263. {name: 1656864000000, value: 295},
  264. {name: 1656867600000, value: 260},
  265. {name: 1656871200000, value: 292},
  266. {name: 1656874800000, value: 242},
  267. {name: 1656878400000, value: 318},
  268. {name: 1656882000000, value: 326},
  269. {name: 1656885600000, value: 302},
  270. {name: 1656889200000, value: 299},
  271. {name: 1656892800000, value: 299},
  272. {name: 1656896400000, value: 321},
  273. {name: 1656900000000, value: 310},
  274. {name: 1656903600000, value: 320},
  275. {name: 1656907200000, value: 371},
  276. {name: 1656910800000, value: 323},
  277. {name: 1656914400000, value: 331},
  278. {name: 1656918000000, value: 286},
  279. {name: 1656921600000, value: 256},
  280. {name: 1656925200000, value: 275},
  281. {name: 1656928800000, value: 316},
  282. {name: 1656932400000, value: 294},
  283. {name: 1656936000000, value: 295},
  284. {name: 1656939600000, value: 301},
  285. {name: 1656943200000, value: 282},
  286. {name: 1656946800000, value: 391},
  287. {name: 1656950400000, value: 358},
  288. {name: 1656954000000, value: 391},
  289. {name: 1656957600000, value: 217},
  290. ],
  291. barMinHeight: 0,
  292. type: 'bar',
  293. stack: 'usage',
  294. },
  295. {
  296. seriesName: 'Discarded',
  297. color: '#F55459',
  298. data: [
  299. {name: 1656788400000, value: 1177460},
  300. {name: 1656792000000, value: 1128512},
  301. {name: 1656795600000, value: 1052988},
  302. {name: 1656799200000, value: 1039288},
  303. {name: 1656802800000, value: 988404},
  304. {name: 1656806400000, value: 1114932},
  305. {name: 1656810000000, value: 1163848},
  306. {name: 1656813600000, value: 972104},
  307. {name: 1656817200000, value: 971228},
  308. {name: 1656820800000, value: 996920},
  309. {name: 1656824400000, value: 1004984},
  310. {name: 1656828000000, value: 1077316},
  311. {name: 1656831600000, value: 1185548},
  312. {name: 1656835200000, value: 1233680},
  313. {name: 1656838800000, value: 1210668},
  314. {name: 1656842400000, value: 1208732},
  315. {name: 1656846000000, value: 1267876},
  316. {name: 1656849600000, value: 1336536},
  317. {name: 1656853200000, value: 1345832},
  318. {name: 1656856800000, value: 1320080},
  319. {name: 1656860400000, value: 1296032},
  320. {name: 1656864000000, value: 1271436},
  321. {name: 1656867600000, value: 1250668},
  322. {name: 1656871200000, value: 1229200},
  323. {name: 1656874800000, value: 1207692},
  324. {name: 1656878400000, value: 1199880},
  325. {name: 1656882000000, value: 1108700},
  326. {name: 1656885600000, value: 1099152},
  327. {name: 1656889200000, value: 1197136},
  328. {name: 1656892800000, value: 1473788},
  329. {name: 1656896400000, value: 1779020},
  330. {name: 1656900000000, value: 1693716},
  331. {name: 1656903600000, value: 1665720},
  332. {name: 1656907200000, value: 1859256},
  333. {name: 1656910800000, value: 2106840},
  334. {name: 1656914400000, value: 2770524},
  335. {name: 1656918000000, value: 2881248},
  336. {name: 1656921600000, value: 2880440},
  337. {name: 1656925200000, value: 2879732},
  338. {name: 1656928800000, value: 2878212},
  339. {name: 1656932400000, value: 2872732},
  340. {name: 1656936000000, value: 2880208},
  341. {name: 1656939600000, value: 2873792},
  342. {name: 1656943200000, value: 2880500},
  343. {name: 1656946800000, value: 2849960},
  344. {name: 1656950400000, value: 2573544},
  345. {name: 1656954000000, value: 2181824},
  346. {name: 1656957600000, value: 1246108},
  347. ],
  348. barMinHeight: 0,
  349. type: 'bar',
  350. stack: 'usage',
  351. },
  352. ]);
  353. });
  354. });