Skip to content

Commit

Permalink
cost page: fix for when there are no parameters set, default to 7 days (
Browse files Browse the repository at this point in the history
  • Loading branch information
wdvr authored Dec 13, 2024
1 parent 3b7d886 commit 6c5ce24
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions torchci/pages/cost_analysis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,27 +193,22 @@ export default function Page() {

const { query } = router;

// if initialDateRange is not set, set it to -1. If it is set, parse it to an integer, and if that fails, set it to 7
let initialDateRange = query.dateRange
? parseInt(query.dateRange as string)
: -1;

// on invalid entry, set initialDateRange to 7
if (isNaN(initialDateRange)) {
initialDateRange = 7;
}

const initialStartDate = query.dateRange
? dayjs().subtract(initialDateRange, "day")
: query.startDate
? dayjs(query.startDate as string)
: dayjs();
const initialEndDate = query.dateRange
? dayjs()
: query.endDate
const initialEndDate = query.endDate
? dayjs(query.endDate as string)
: dayjs();

const initialStartDate = query.startDate
? dayjs(query.startDate as string)
: query.dateRange
? dayjs().subtract(parseInt(query.dateRange as string), "day")
: dayjs().subtract(7, "day");

const initialDateRange = query.dateRange
? parseInt(query.dateRange as string)
: query.startDate || query.endDate
? -1
: 7;

const initialGranularity = query.granularity || "day";
const initialGroupBy = query.groupby || "workflow_name";
const initialChartType = query.chartType || "stacked_bar";
Expand Down

0 comments on commit 6c5ce24

Please sign in to comment.