Skip to content

Commit

Permalink
Added to WSOD fix on metrics tab
Browse files Browse the repository at this point in the history
When selecting date, the following behavior occurs:
- If 2+ days, behave as normal (Range of Day1 -> Day2)
- If  "open Ended" (i.e., only start is picked), fetch
  a range of days between that day and present (Day1 -> Today)
- If 1 day, fetch range for 48 hours from that day

TODO: The 1 day range going to 48 hours is meant as a patch, so that
this WSOD fix can go to staging.  To make a single day only fetch
24 hrs, some changes to the server may be needed.
  • Loading branch information
the-bay-kay committed Jan 9, 2024
1 parent 588f685 commit 5166bef
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions www/js/metrics/MetricsDateSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,24 @@ const MetricsDateSelect = ({ dateRange, setDateRange }: Props) => {

const onChoose = useCallback(
({ startDate, endDate }) => {
const dtStartDate = DateTime.fromJSDate(startDate).startOf('day')
const dtStartDate = DateTime.fromJSDate(startDate).startOf('day');
let dtEndDate;
if(!endDate) { // For when only one day is selected
dtEndDate = dtStartDate.endOf('day').minus({minutes: 1});
}
else {
dtEndDate = DateTime.fromJSDate(endDate).startOf('day')

if (!endDate) {
// If no end date selected, pull range from then till present day
dtEndDate = DateTime.now();
} else if (
dtStartDate.toString() === DateTime.fromJSDate(endDate).startOf('day').toString()
) {
// For when only one day is selected
// NOTE: As written, this technically timestamp will technically fetch _two_ days.
// For more info, see: https://github.com/e-mission/e-mission-docs/issues/1027
dtEndDate = dtStartDate.endOf('day');
} else {
dtEndDate = DateTime.fromJSDate(endDate).startOf('day');
}
setOpen(false);
setDateRange([
dtStartDate,
dtEndDate,
]);
setDateRange([dtStartDate, dtEndDate]);
},
[setOpen, setDateRange],
);
Expand Down

0 comments on commit 5166bef

Please sign in to comment.