MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / getTimeRange

Function getTimeRange

console/src/platform/billing/queries.ts:79–94  ·  view source on GitHub ↗
(span: number)

Source from the content-addressed store, hash-verified

77}
78
79export 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
96export function useDailyCosts(timeSpan: number, queryTime: Date) {
97 return useQuery({

Callers 3

UsagePage.test.tsxFile · 0.90
useDailyCostsFunction · 0.85

Calls 2

nowUTCFunction · 0.90
maxMethod · 0.45

Tested by

no test coverage detected