🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
filter out future dates
Bill Yang79ecfc601562
diff --git a/client/src/app/[site]/components/MainSection/Chart.tsx b/client/src/app/[site]/components/MainSection/Chart.tsxindex 5b19f1c65..37b331861 100644--- a/client/src/app/[site]/components/MainSection/Chart.tsx+++ b/client/src/app/[site]/components/MainSection/Chart.tsx@@ -80,17 +80,26 @@ export function Chart({0);- const formattedData = data?.data?.map((e, i) => ({- x: DateTime.fromSQL(e.time).toUTC().toFormat("yyyy-MM-dd HH:mm:ss"),- y: e.pageviews,- previousY:- i >= lengthDiff && previousData?.data?.[i - lengthDiff]?.pageviews,- currentTime: DateTime.fromSQL(e.time),- previousTime:- i >= lengthDiff- ? DateTime.fromSQL(previousData?.data?.[i - lengthDiff]?.time ?? "")- : undefined,- }));+ const formattedData = data?.data+ ?.map((e, i) => {+ // filter out dates from the future+ if (DateTime.fromSQL(e.time).toUTC() > DateTime.now()) {+ return null;+ }++ return {+ x: DateTime.fromSQL(e.time).toUTC().toFormat("yyyy-MM-dd HH:mm:ss"),+ y: e.pageviews,+ previousY:+ i >= lengthDiff && previousData?.data?.[i - lengthDiff]?.pageviews,+ currentTime: DateTime.fromSQL(e.time),+ previousTime:+ i >= lengthDiff+ ? DateTime.fromSQL(previousData?.data?.[i - lengthDiff]?.time ?? "")+ : undefined,+ };+ })+ .filter((e) => e !== null);return (<ResponsiveLine