From fabc4a6c0cd177776ef4028ac23cb2244d345c33 Mon Sep 17 00:00:00 2001 From: Fran Date: Wed, 24 Jul 2024 22:41:28 +0200 Subject: [PATCH 1/2] fix x periods --- .../projectTotalsGraph/projectTotalsGraph.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/nextjs/components/onchain-impact-dashboard/projectTotalsGraph/projectTotalsGraph.tsx b/packages/nextjs/components/onchain-impact-dashboard/projectTotalsGraph/projectTotalsGraph.tsx index 44f9963..ce5796d 100644 --- a/packages/nextjs/components/onchain-impact-dashboard/projectTotalsGraph/projectTotalsGraph.tsx +++ b/packages/nextjs/components/onchain-impact-dashboard/projectTotalsGraph/projectTotalsGraph.tsx @@ -33,6 +33,9 @@ export const ProjectTotalsGraph = ({ totalsRecord, filter, }: IProps) => { + console.log(filter); + const intFilter = parseInt(filter) >= 60 ? 30 : parseInt(filter) > 7 ? 7 : 1; + const tickInterval = 24 * 3600 * 1000; const options = { chart: { type: "line", @@ -49,6 +52,7 @@ export const ProjectTotalsGraph = ({ }, xAxis: { type: "datetime", + tickInterval: intFilter * tickInterval, title: { text: "", }, From 44fb4c4e456658bc22d5754b636daf25a5643902 Mon Sep 17 00:00:00 2001 From: Fran Date: Thu, 25 Jul 2024 00:17:27 +0200 Subject: [PATCH 2/2] fix dates in endpoint --- .../leaderBoardComponent/leaderBoardComponent.tsx | 2 +- .../projectTotalsGraph/projectTotalsGraph.tsx | 1 - .../onchainImpactDashboardApi/globalScoreServices.ts | 9 +++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/nextjs/components/onchain-impact-dashboard/leaderBoardComponent/leaderBoardComponent.tsx b/packages/nextjs/components/onchain-impact-dashboard/leaderBoardComponent/leaderBoardComponent.tsx index 8c04ba9..7539445 100644 --- a/packages/nextjs/components/onchain-impact-dashboard/leaderBoardComponent/leaderBoardComponent.tsx +++ b/packages/nextjs/components/onchain-impact-dashboard/leaderBoardComponent/leaderBoardComponent.tsx @@ -51,7 +51,7 @@ export const LeaderBoardComponent = () => { return; } if (val != "" && valEnd != "") { - getScores(`${val},${valEnd}`); + getScores(`${startDate},${endDate}`); } }, [startDate, endDate]); diff --git a/packages/nextjs/components/onchain-impact-dashboard/projectTotalsGraph/projectTotalsGraph.tsx b/packages/nextjs/components/onchain-impact-dashboard/projectTotalsGraph/projectTotalsGraph.tsx index ce5796d..e4bd9e6 100644 --- a/packages/nextjs/components/onchain-impact-dashboard/projectTotalsGraph/projectTotalsGraph.tsx +++ b/packages/nextjs/components/onchain-impact-dashboard/projectTotalsGraph/projectTotalsGraph.tsx @@ -33,7 +33,6 @@ export const ProjectTotalsGraph = ({ totalsRecord, filter, }: IProps) => { - console.log(filter); const intFilter = parseInt(filter) >= 60 ? 30 : parseInt(filter) > 7 ? 7 : 1; const tickInterval = 24 * 3600 * 1000; const options = { diff --git a/packages/nextjs/services/onchainImpactDashboardApi/globalScoreServices.ts b/packages/nextjs/services/onchainImpactDashboardApi/globalScoreServices.ts index 9ca2e53..dfb9f69 100644 --- a/packages/nextjs/services/onchainImpactDashboardApi/globalScoreServices.ts +++ b/packages/nextjs/services/onchainImpactDashboardApi/globalScoreServices.ts @@ -4,16 +4,17 @@ export const GlobalScoreService = () => { const baseURL = `${process.env.NEXT_PUBLIC_API_URL}/globalScore`; const getGlobalScores = async (filter?: string) => { let url = `${baseURL}`; + let startDate = new Date(); + let endDate = new Date(); if (filter) { if (filter.includes(",")) { const [start, end] = filter.split(","); - url += `?startDate=${start}&endDate=${end}`; + startDate = new Date(start); + endDate = new Date(end); } else if (typeof parseInt(filter) === "number") { - const startDate = new Date(); startDate.setDate(startDate.getDate() - parseInt(filter)); - const endDate = new Date(); - url += `?startDate=${startDate.toISOString()}&endDate=${endDate.toISOString()}`; } + url += `?startDate=${startDate.toISOString()}&endDate=${endDate.toISOString()}`; } const response = await fetch(url); const { data }: { data: IGlobalScore[] } = await response.json();