Refactor VSD api requests
What does this MR do and why?
This refactor MR provides a starting point for:
- Exec dashboards: Refactor API requests from RES... (#384560 - closed) - Related MR
- Value Streams Dashboard: Add Vulnerabilities me... (#383697 - closed) - Related MR
Background
Currently the VSD page uses the summary
and time_summary
REST endpoints to fetch the metrics for the page. These endpoints return aggregated counts based on the date range (start->end date) specified. There are 2 sets time periods we need to request, for example for on May 2 we would fetch data over these 2 time periods:
- dashboard time periods: [May 1 - May 2, April 1 - April 30, Mar 1 - Mar 31, Feb 1 - Feb 28]
- chart time periods: [Apr 2 - May 2, Mar 2 - Apr 2, .... Nov 2 - Dec 2]
With the switch to the dora + flowmetrics graphql endpoints as well as the addition of vulnerability counts by day, we will have a mixture of aggregated data and time series data. To display the data in the VSD page we will need to fetch the data, transform it into a consistent format aggregated and then combine the results for display in the table as well as the sparklines.
This refactor introduces fetchMetricsForTimePeriods
which accepts an array of start/end dates, as well as a function to query and will return a mapping of time periods with their aggregate metric values, ready to be displayed in the table or as a sparkline. This will allow us to introduce vulnerability counts by day (only available in graphql) alongside the REST api requests, while also working on dora + flowmetrics graphql endpoints which will be behind a feature flag while we evaluate the new endpoints.
Screenshots or screen recordings
No visual changes
How to set up and validate locally
All tests pass
$ yarn jest analytics/dashboards
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #383697 (closed)