(span: number)
| 77 | } |
| 78 | |
| 79 | export function getTimeRange(span: number): [Date, Date] { |
| 80 | // Some fields on the usage page, such as the rolling average in the plan |
| 81 | // details component, requires a certain number of days' worth of data. That |
| 82 | // span of time may be greater than what is being visually filtered, so set |
| 83 | // the minimum-queried range to what the rolling average needs. |
| 84 | span = Math.max(span, ROLLING_AVG_TIME_RANGE_LOOKBACK_DAYS); |
| 85 | const endDate = startOfDay(addDays(nowUTC(), 1)); |
| 86 | endDate.setUTCHours(0, 0, 0, 0); |
| 87 | const startDate = new Date( |
| 88 | subDays(endDate, span) |
| 89 | // Since we're bucketing these by day, start from the beginning of the |
| 90 | // UTC day. |
| 91 | .setUTCHours(0, 0, 0, 0), |
| 92 | ); |
| 93 | return [startDate, endDate]; |
| 94 | } |
| 95 | |
| 96 | export function useDailyCosts(timeSpan: number, queryTime: Date) { |
| 97 | return useQuery({ |
no test coverage detected