projectStatsToPredictedSeries.spec.tsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. import {projectStatsToPredictedSeries} from 'sentry/views/settings/project/server-side-sampling/utils/projectStatsToPredictedSeries';
  2. import {outcomesWithoutClientDiscarded} from '../testUtils';
  3. describe('projectStatsToPredictedSeries', function () {
  4. it('returns correct series', function () {
  5. expect(
  6. projectStatsToPredictedSeries(TestStubs.OutcomesWithReason(), 0.3, 0.1)
  7. ).toEqual([
  8. {
  9. seriesName: 'Indexed and Processed',
  10. color: '#2BA185',
  11. barMinHeight: 0,
  12. type: 'bar',
  13. stack: 'predictedUsage',
  14. data: [
  15. {name: 1656788400000, value: 29437},
  16. {name: 1656792000000, value: 28213},
  17. {name: 1656795600000, value: 26325},
  18. {name: 1656799200000, value: 25982},
  19. {name: 1656802800000, value: 24720},
  20. {name: 1656806400000, value: 27873},
  21. {name: 1656810000000, value: 29096},
  22. {name: 1656813600000, value: 24303},
  23. {name: 1656817200000, value: 24337},
  24. {name: 1656820800000, value: 24941},
  25. {name: 1656824400000, value: 25125},
  26. {name: 1656828000000, value: 26933},
  27. {name: 1656831600000, value: 29639},
  28. {name: 1656835200000, value: 30842},
  29. {name: 1656838800000, value: 30289},
  30. {name: 1656842400000, value: 30219},
  31. {name: 1656846000000, value: 31726},
  32. {name: 1656849600000, value: 33460},
  33. {name: 1656853200000, value: 33654},
  34. {name: 1656856800000, value: 33003},
  35. {name: 1656860400000, value: 32401},
  36. {name: 1656864000000, value: 31969},
  37. {name: 1656867600000, value: 31281},
  38. {name: 1656871200000, value: 30730},
  39. {name: 1656874800000, value: 30192},
  40. {name: 1656878400000, value: 29997},
  41. {name: 1656882000000, value: 27718},
  42. {name: 1656885600000, value: 27479},
  43. {name: 1656889200000, value: 29928},
  44. {name: 1656892800000, value: 36845},
  45. {name: 1656896400000, value: 44476},
  46. {name: 1656900000000, value: 42343},
  47. {name: 1656903600000, value: 41643},
  48. {name: 1656907200000, value: 46482},
  49. {name: 1656910800000, value: 52756},
  50. {name: 1656914400000, value: 71796},
  51. {name: 1656918000000, value: 86751},
  52. {name: 1656921600000, value: 94012},
  53. {name: 1656925200000, value: 90893},
  54. {name: 1656928800000, value: 81914},
  55. {name: 1656932400000, value: 79947},
  56. {name: 1656936000000, value: 85457},
  57. {name: 1656939600000, value: 86994},
  58. {name: 1656943200000, value: 84871},
  59. {name: 1656946800000, value: 75413},
  60. {name: 1656950400000, value: 64979},
  61. {name: 1656954000000, value: 54560},
  62. {name: 1656957600000, value: 31291},
  63. ],
  64. },
  65. {
  66. seriesName: 'Processed',
  67. color: '#F5B000',
  68. data: [
  69. {name: 1656788400000, value: 58873},
  70. {name: 1656792000000, value: 56426},
  71. {name: 1656795600000, value: 52650},
  72. {name: 1656799200000, value: 51965},
  73. {name: 1656802800000, value: 49439},
  74. {name: 1656806400000, value: 55747},
  75. {name: 1656810000000, value: 58193},
  76. {name: 1656813600000, value: 48605},
  77. {name: 1656817200000, value: 48675},
  78. {name: 1656820800000, value: 49882},
  79. {name: 1656824400000, value: 50249},
  80. {name: 1656828000000, value: 53866},
  81. {name: 1656831600000, value: 59278},
  82. {name: 1656835200000, value: 61684},
  83. {name: 1656838800000, value: 60578},
  84. {name: 1656842400000, value: 60438},
  85. {name: 1656846000000, value: 63451},
  86. {name: 1656849600000, value: 66920},
  87. {name: 1656853200000, value: 67308},
  88. {name: 1656856800000, value: 66005},
  89. {name: 1656860400000, value: 64802},
  90. {name: 1656864000000, value: 63939},
  91. {name: 1656867600000, value: 62562},
  92. {name: 1656871200000, value: 61460},
  93. {name: 1656874800000, value: 60385},
  94. {name: 1656878400000, value: 59994},
  95. {name: 1656882000000, value: 55435},
  96. {name: 1656885600000, value: 54958},
  97. {name: 1656889200000, value: 59857},
  98. {name: 1656892800000, value: 73690},
  99. {name: 1656896400000, value: 88951},
  100. {name: 1656900000000, value: 84686},
  101. {name: 1656903600000, value: 83286},
  102. {name: 1656907200000, value: 92963},
  103. {name: 1656910800000, value: 105512},
  104. {name: 1656914400000, value: 143592},
  105. {name: 1656918000000, value: 173502},
  106. {name: 1656921600000, value: 188025},
  107. {name: 1656925200000, value: 181787},
  108. {name: 1656928800000, value: 163829},
  109. {name: 1656932400000, value: 159894},
  110. {name: 1656936000000, value: 170915},
  111. {name: 1656939600000, value: 173987},
  112. {name: 1656943200000, value: 169742},
  113. {name: 1656946800000, value: 150827},
  114. {name: 1656950400000, value: 129958},
  115. {name: 1656954000000, value: 109120},
  116. {name: 1656957600000, value: 62582},
  117. ],
  118. barMinHeight: 0,
  119. type: 'bar',
  120. stack: 'predictedUsage',
  121. },
  122. {
  123. seriesName: 'Discarded',
  124. color: '#F55459',
  125. data: [
  126. {name: 1656788400000, value: 206056},
  127. {name: 1656792000000, value: 197490},
  128. {name: 1656795600000, value: 184274},
  129. {name: 1656799200000, value: 181876},
  130. {name: 1656802800000, value: 173037},
  131. {name: 1656806400000, value: 195114},
  132. {name: 1656810000000, value: 203674},
  133. {name: 1656813600000, value: 170118},
  134. {name: 1656817200000, value: 170361},
  135. {name: 1656820800000, value: 174586},
  136. {name: 1656824400000, value: 175873},
  137. {name: 1656828000000, value: 188531},
  138. {name: 1656831600000, value: 207472},
  139. {name: 1656835200000, value: 215894},
  140. {name: 1656838800000, value: 212022},
  141. {name: 1656842400000, value: 211532},
  142. {name: 1656846000000, value: 222079},
  143. {name: 1656849600000, value: 234219},
  144. {name: 1656853200000, value: 235579},
  145. {name: 1656856800000, value: 231019},
  146. {name: 1656860400000, value: 226806},
  147. {name: 1656864000000, value: 223786},
  148. {name: 1656867600000, value: 218968},
  149. {name: 1656871200000, value: 215110},
  150. {name: 1656874800000, value: 211346},
  151. {name: 1656878400000, value: 209980},
  152. {name: 1656882000000, value: 194023},
  153. {name: 1656885600000, value: 192352},
  154. {name: 1656889200000, value: 209499},
  155. {name: 1656892800000, value: 257914},
  156. {name: 1656896400000, value: 311329},
  157. {name: 1656900000000, value: 296402},
  158. {name: 1656903600000, value: 291501},
  159. {name: 1656907200000, value: 325371},
  160. {name: 1656910800000, value: 369291},
  161. {name: 1656914400000, value: 502573},
  162. {name: 1656918000000, value: 607258},
  163. {name: 1656921600000, value: 658087},
  164. {name: 1656925200000, value: 636254},
  165. {name: 1656928800000, value: 573400},
  166. {name: 1656932400000, value: 559630},
  167. {name: 1656936000000, value: 598202},
  168. {name: 1656939600000, value: 608956},
  169. {name: 1656943200000, value: 594097},
  170. {name: 1656946800000, value: 527893},
  171. {name: 1656950400000, value: 454853},
  172. {name: 1656954000000, value: 381921},
  173. {name: 1656957600000, value: 219036},
  174. ],
  175. barMinHeight: 0,
  176. type: 'bar',
  177. stack: 'predictedUsage',
  178. },
  179. ]);
  180. });
  181. it('handles outcomes without client reports', function () {
  182. expect(
  183. projectStatsToPredictedSeries(outcomesWithoutClientDiscarded, 0.3, 0.1, 0.2)
  184. ).toEqual([
  185. {
  186. seriesName: 'Indexed and Processed',
  187. color: '#2BA185',
  188. barMinHeight: 0,
  189. type: 'bar',
  190. stack: 'predictedUsage',
  191. data: [
  192. {name: 1656788400000, value: 147183},
  193. {name: 1656792000000, value: 141064},
  194. {name: 1656795600000, value: 131624},
  195. {name: 1656799200000, value: 129911},
  196. {name: 1656802800000, value: 123551},
  197. {name: 1656806400000, value: 139367},
  198. {name: 1656810000000, value: 145481},
  199. {name: 1656813600000, value: 121513},
  200. {name: 1656817200000, value: 121404},
  201. {name: 1656820800000, value: 124615},
  202. {name: 1656824400000, value: 125623},
  203. {name: 1656828000000, value: 134665},
  204. {name: 1656831600000, value: 148194},
  205. {name: 1656835200000, value: 154210},
  206. {name: 1656838800000, value: 151334},
  207. {name: 1656842400000, value: 151092},
  208. {name: 1656846000000, value: 158485},
  209. {name: 1656849600000, value: 167067},
  210. {name: 1656853200000, value: 168229},
  211. {name: 1656856800000, value: 165010},
  212. {name: 1656860400000, value: 162004},
  213. {name: 1656864000000, value: 158930},
  214. {name: 1656867600000, value: 156334},
  215. {name: 1656871200000, value: 153650},
  216. {name: 1656874800000, value: 150962},
  217. {name: 1656878400000, value: 149985},
  218. {name: 1656882000000, value: 138588},
  219. {name: 1656885600000, value: 137394},
  220. {name: 1656889200000, value: 149642},
  221. {name: 1656892800000, value: 184224},
  222. {name: 1656896400000, value: 222378},
  223. {name: 1656900000000, value: 211715},
  224. {name: 1656903600000, value: 208215},
  225. {name: 1656907200000, value: 232407},
  226. {name: 1656910800000, value: 263355},
  227. {name: 1656914400000, value: 346316},
  228. {name: 1656918000000, value: 360156},
  229. {name: 1656921600000, value: 360055},
  230. {name: 1656925200000, value: 359967},
  231. {name: 1656928800000, value: 359777},
  232. {name: 1656932400000, value: 359092},
  233. {name: 1656936000000, value: 360026},
  234. {name: 1656939600000, value: 359224},
  235. {name: 1656943200000, value: 360063},
  236. {name: 1656946800000, value: 356245},
  237. {name: 1656950400000, value: 321693},
  238. {name: 1656954000000, value: 272728},
  239. {name: 1656957600000, value: 155764},
  240. ],
  241. },
  242. {
  243. seriesName: 'Processed',
  244. color: '#F5B000',
  245. data: [
  246. {name: 1656788400000, value: 294365},
  247. {name: 1656792000000, value: 282128},
  248. {name: 1656795600000, value: 263247},
  249. {name: 1656799200000, value: 259822},
  250. {name: 1656802800000, value: 247101},
  251. {name: 1656806400000, value: 278733},
  252. {name: 1656810000000, value: 290962},
  253. {name: 1656813600000, value: 243026},
  254. {name: 1656817200000, value: 242807},
  255. {name: 1656820800000, value: 249230},
  256. {name: 1656824400000, value: 251246},
  257. {name: 1656828000000, value: 269329},
  258. {name: 1656831600000, value: 296387},
  259. {name: 1656835200000, value: 308420},
  260. {name: 1656838800000, value: 302667},
  261. {name: 1656842400000, value: 302183},
  262. {name: 1656846000000, value: 316969},
  263. {name: 1656849600000, value: 334134},
  264. {name: 1656853200000, value: 336458},
  265. {name: 1656856800000, value: 330020},
  266. {name: 1656860400000, value: 324008},
  267. {name: 1656864000000, value: 317859},
  268. {name: 1656867600000, value: 312667},
  269. {name: 1656871200000, value: 307300},
  270. {name: 1656874800000, value: 301923},
  271. {name: 1656878400000, value: 299970},
  272. {name: 1656882000000, value: 277175},
  273. {name: 1656885600000, value: 274788},
  274. {name: 1656889200000, value: 299284},
  275. {name: 1656892800000, value: 368447},
  276. {name: 1656896400000, value: 444755},
  277. {name: 1656900000000, value: 423429},
  278. {name: 1656903600000, value: 416430},
  279. {name: 1656907200000, value: 464814},
  280. {name: 1656910800000, value: 526710},
  281. {name: 1656914400000, value: 692631},
  282. {name: 1656918000000, value: 720312},
  283. {name: 1656921600000, value: 720110},
  284. {name: 1656925200000, value: 719933},
  285. {name: 1656928800000, value: 719553},
  286. {name: 1656932400000, value: 718183},
  287. {name: 1656936000000, value: 720052},
  288. {name: 1656939600000, value: 718448},
  289. {name: 1656943200000, value: 720125},
  290. {name: 1656946800000, value: 712490},
  291. {name: 1656950400000, value: 643386},
  292. {name: 1656954000000, value: 545456},
  293. {name: 1656957600000, value: 311527},
  294. ],
  295. barMinHeight: 0,
  296. type: 'bar',
  297. stack: 'predictedUsage',
  298. },
  299. {
  300. seriesName: 'Discarded',
  301. color: '#F55459',
  302. data: [
  303. {name: 1656788400000, value: 1030278},
  304. {name: 1656792000000, value: 987448},
  305. {name: 1656795600000, value: 921365},
  306. {name: 1656799200000, value: 909377},
  307. {name: 1656802800000, value: 864854},
  308. {name: 1656806400000, value: 975566},
  309. {name: 1656810000000, value: 1018367},
  310. {name: 1656813600000, value: 850591},
  311. {name: 1656817200000, value: 849825},
  312. {name: 1656820800000, value: 872305},
  313. {name: 1656824400000, value: 879361},
  314. {name: 1656828000000, value: 942652},
  315. {name: 1656831600000, value: 1037355},
  316. {name: 1656835200000, value: 1079470},
  317. {name: 1656838800000, value: 1059335},
  318. {name: 1656842400000, value: 1057641},
  319. {name: 1656846000000, value: 1109392},
  320. {name: 1656849600000, value: 1169469},
  321. {name: 1656853200000, value: 1177603},
  322. {name: 1656856800000, value: 1155070},
  323. {name: 1656860400000, value: 1134028},
  324. {name: 1656864000000, value: 1112507},
  325. {name: 1656867600000, value: 1094335},
  326. {name: 1656871200000, value: 1075550},
  327. {name: 1656874800000, value: 1056731},
  328. {name: 1656878400000, value: 1049895},
  329. {name: 1656882000000, value: 970113},
  330. {name: 1656885600000, value: 961758},
  331. {name: 1656889200000, value: 1047494},
  332. {name: 1656892800000, value: 1289565},
  333. {name: 1656896400000, value: 1556643},
  334. {name: 1656900000000, value: 1482002},
  335. {name: 1656903600000, value: 1457505},
  336. {name: 1656907200000, value: 1626849},
  337. {name: 1656910800000, value: 1843485},
  338. {name: 1656914400000, value: 2424209},
  339. {name: 1656918000000, value: 2521092},
  340. {name: 1656921600000, value: 2520385},
  341. {name: 1656925200000, value: 2519766},
  342. {name: 1656928800000, value: 2518436},
  343. {name: 1656932400000, value: 2513641},
  344. {name: 1656936000000, value: 2520182},
  345. {name: 1656939600000, value: 2514568},
  346. {name: 1656943200000, value: 2520438},
  347. {name: 1656946800000, value: 2493715},
  348. {name: 1656950400000, value: 2251851},
  349. {name: 1656954000000, value: 1909096},
  350. {name: 1656957600000, value: 1090345},
  351. ],
  352. barMinHeight: 0,
  353. type: 'bar',
  354. stack: 'predictedUsage',
  355. },
  356. ]);
  357. });
  358. });