From 8e600757685fcc03770a795448c2cb2f6537bb97 Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Tue, 14 May 2024 15:47:16 +0530 Subject: [PATCH 1/3] fix: explorer not showing DG --- packages/data-layer/src/data.types.ts | 1 + packages/grant-explorer/src/features/api/rounds.ts | 2 +- .../src/features/discovery/ExploreRoundsPage.tsx | 5 ++++- .../discovery/utils/createRoundsStatusFilter.ts | 10 ++++------ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/data-layer/src/data.types.ts b/packages/data-layer/src/data.types.ts index 2d05d302f2..6c2b505aeb 100644 --- a/packages/data-layer/src/data.types.ts +++ b/packages/data-layer/src/data.types.ts @@ -508,6 +508,7 @@ export type TimeFilterVariables = { applicationsEndTime?: TimeFilter; donationsStartTime?: TimeFilter; donationsEndTime?: TimeFilter; + or?: any; }; export type RoundsQueryVariables = { diff --git a/packages/grant-explorer/src/features/api/rounds.ts b/packages/grant-explorer/src/features/api/rounds.ts index 14ded46943..4dbc249367 100644 --- a/packages/grant-explorer/src/features/api/rounds.ts +++ b/packages/grant-explorer/src/features/api/rounds.ts @@ -18,7 +18,7 @@ export const useRounds = ( fetchSpamRounds(), dataLayer.getRounds({ ...variables, - first: 100, + first: 500, chainIds, }), ]); diff --git a/packages/grant-explorer/src/features/discovery/ExploreRoundsPage.tsx b/packages/grant-explorer/src/features/discovery/ExploreRoundsPage.tsx index 0880fb588f..51e482418a 100644 --- a/packages/grant-explorer/src/features/discovery/ExploreRoundsPage.tsx +++ b/packages/grant-explorer/src/features/discovery/ExploreRoundsPage.tsx @@ -18,6 +18,9 @@ const ExploreRoundsPage = () => { // Pass the filter from the search params and build the graphql query const rounds = useFilterRounds(filter, getEnabledChains()); + const publicRounds = rounds.data?.filter(round => round.roundMetadata.roundType?.toLowerCase() !== "private"); + rounds.data = publicRounds; + const sectionTitle = getExplorerPageTitle(filter); return ( @@ -25,7 +28,7 @@ const ExploreRoundsPage = () => { } > diff --git a/packages/grant-explorer/src/features/discovery/utils/createRoundsStatusFilter.ts b/packages/grant-explorer/src/features/discovery/utils/createRoundsStatusFilter.ts index f12dd358bb..fe8b574f90 100644 --- a/packages/grant-explorer/src/features/discovery/utils/createRoundsStatusFilter.ts +++ b/packages/grant-explorer/src/features/discovery/utils/createRoundsStatusFilter.ts @@ -7,21 +7,19 @@ export const createISOTimestamp = (timestamp = 0) => { }; const ONE_DAY_IN_MILISECONDS = 3600 * 24 * 1000; -const ONE_YEAR_IN_MILISECONDS = ONE_DAY_IN_MILISECONDS * 365 * 1000; function getStatusFilter(status: string): TimeFilterVariables { const currentTimestamp = createISOTimestamp(); - const futureTimestamp = createISOTimestamp(ONE_YEAR_IN_MILISECONDS); switch (status) { case RoundStatus.active: return { // Round must have started and not ended yet donationsStartTime: { lessThan: currentTimestamp }, - donationsEndTime: { - greaterThan: currentTimestamp, - lessThan: futureTimestamp, - }, + or: [ + { donationsEndTime: { greaterThan: currentTimestamp} }, + { donationsEndTime: { isNull: true } }, + ] }; case RoundStatus.taking_applications: return { From 9fc121dbe1aa3ef0b3da9c7c5524480a75873726 Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Tue, 14 May 2024 16:02:23 +0530 Subject: [PATCH 2/3] fix test --- packages/data-layer/src/data.types.ts | 3 ++- .../utils/__tests__/createRoundsStatusFilter.test.tsx | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/data-layer/src/data.types.ts b/packages/data-layer/src/data.types.ts index 6c2b505aeb..bf28555e83 100644 --- a/packages/data-layer/src/data.types.ts +++ b/packages/data-layer/src/data.types.ts @@ -501,6 +501,7 @@ export type TimeFilter = { lessThan?: string; greaterThanOrEqualTo?: string; lessThanOrEqualTo?: string; + isNull?: boolean; }; export type TimeFilterVariables = { @@ -508,7 +509,7 @@ export type TimeFilterVariables = { applicationsEndTime?: TimeFilter; donationsStartTime?: TimeFilter; donationsEndTime?: TimeFilter; - or?: any; + or?: TimeFilterVariables[]; }; export type RoundsQueryVariables = { diff --git a/packages/grant-explorer/src/features/discovery/utils/__tests__/createRoundsStatusFilter.test.tsx b/packages/grant-explorer/src/features/discovery/utils/__tests__/createRoundsStatusFilter.test.tsx index 61f8fe222e..be72ee70c0 100644 --- a/packages/grant-explorer/src/features/discovery/utils/__tests__/createRoundsStatusFilter.test.tsx +++ b/packages/grant-explorer/src/features/discovery/utils/__tests__/createRoundsStatusFilter.test.tsx @@ -5,8 +5,9 @@ describe("createRoundsStatusFilter", () => { const filter = createRoundsStatusFilter("active"); expect(filter[0].donationsStartTime?.lessThan).toBeDefined(); - expect(filter[0].donationsEndTime?.greaterThan).toBeDefined(); - expect(filter[0].donationsEndTime?.lessThan).toBeDefined(); + expect(filter[0]?.or!.length).toBe(2); + expect(filter[0]!.or![0]!.donationsEndTime?.greaterThan).toBeDefined(); // Added null check + expect(filter[0]!.or![1]!.donationsEndTime?.isNull).toBeDefined(); }); it("multi selected filters", async () => { const filter = createRoundsStatusFilter( From bf3a4bee310cebae2a5af40a00569dbd734743d0 Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Tue, 14 May 2024 17:16:08 +0530 Subject: [PATCH 3/3] address feedback --- .../src/features/discovery/ExploreRoundsPage.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/grant-explorer/src/features/discovery/ExploreRoundsPage.tsx b/packages/grant-explorer/src/features/discovery/ExploreRoundsPage.tsx index 51e482418a..135efc70b2 100644 --- a/packages/grant-explorer/src/features/discovery/ExploreRoundsPage.tsx +++ b/packages/grant-explorer/src/features/discovery/ExploreRoundsPage.tsx @@ -10,6 +10,7 @@ import { RoundsFilter } from "./RoundsFilter"; import { getExplorerPageTitle } from "./utils/getExplorerPageTitle"; import { RoundsGrid } from "./RoundsGrid"; import { getEnabledChains } from "../../app/chainConfig"; +import { useMemo } from "react"; const ExploreRoundsPage = () => { const [params] = useSearchParams(); @@ -18,7 +19,7 @@ const ExploreRoundsPage = () => { // Pass the filter from the search params and build the graphql query const rounds = useFilterRounds(filter, getEnabledChains()); - const publicRounds = rounds.data?.filter(round => round.roundMetadata.roundType?.toLowerCase() !== "private"); + const publicRounds = useMemo(() => rounds.data?.filter(round => round.roundMetadata.roundType?.toLowerCase() !== "private"), [rounds]); rounds.data = publicRounds; const sectionTitle = getExplorerPageTitle(filter);