Skip to content

Commit e9fa94e

Browse files
committed
Misc bugfixes/todos
1 parent c9a072f commit e9fa94e

2 files changed

Lines changed: 24 additions & 28 deletions

File tree

src/snapshots-app/client/bundles/components/submission/tabs/debugging/PrintStatements.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ const PrintStatements = () => {
163163
justifyContent: "center",
164164
}}
165165
>
166+
{/* TODO investigate bug where backend doesn't have has_print true correctly?? */}
166167
{selectedFileName &&
167168
item.files.find((f) => f.name === selectedFileName)
168169
?.hasPrint && (

src/snapshots-app/client/bundles/components/submission/tabs/summary/BackupCalendarChart.jsx

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,38 +31,33 @@ const BackupCalendarChart = () => {
3131
}, [routeParams]);
3232

3333
const startDate = useMemo(() => {
34-
const keys = Object.keys(rawCalendarData);
35-
if (keys.length === 0) return null;
36-
return Math.min(...keys.map((date) => new Date(date).getTime()));
37-
}, [rawCalendarData]);
34+
const keys = Object.keys(rawCalendarData);
35+
if (keys.length === 0) return null;
36+
// Sort alphabetically to get the earliest string
37+
return keys.sort()[0];
38+
}, [rawCalendarData]);
39+
40+
const endDate = useMemo(() => {
41+
const keys = Object.keys(rawCalendarData);
42+
if (keys.length === 0) return null;
43+
// Sort alphabetically to get the latest string
44+
return keys.sort()[keys.length - 1];
45+
}, [rawCalendarData]);
3846

39-
const endDate = useMemo(() => {
40-
const keys = Object.keys(rawCalendarData);
41-
if (keys.length === 0) return null;
42-
return Math.max(...keys.map((date) => new Date(date).getTime()));
43-
}, [rawCalendarData]);
4447

45-
// generate dummy data
4648
const calendarData = useMemo(() => {
47-
const data = [];
48-
const start = new Date(startDate);
49-
const end = new Date(endDate);
49+
if (!startDate || !endDate) return [];
50+
const data = [];
51+
let curr = new Date(startDate + "T00:00:00"); // Force local time start
52+
const last = new Date(endDate + "T00:00:00");
5053

51-
for (
52-
let time = start.getTime();
53-
time <= end.getTime();
54-
time += 24 * 60 * 60 * 1000
55-
) {
56-
const dateString = echarts.time.format(
57-
new Date(time),
58-
"{yyyy}-{MM}-{dd}",
59-
false,
60-
);
61-
const count = rawCalendarData[dateString] || 0;
62-
data.push([dateString, count]);
63-
}
64-
return data;
65-
}, [rawCalendarData, startDate, endDate]);
54+
while (curr <= last) {
55+
const dateString = echarts.time.format(curr, "{yyyy}-{MM}-{dd}", false);
56+
data.push([dateString, rawCalendarData[dateString] || 0]);
57+
curr.setDate(curr.getDate() + 1); // Native way to increment day
58+
}
59+
return data;
60+
}, [rawCalendarData, startDate, endDate]);
6661

6762
const option = useMemo(
6863
() => ({

0 commit comments

Comments
 (0)