Skip to content

Commit

Permalink
fix: explorer not showing DG (#3432)
Browse files Browse the repository at this point in the history
* fix: explorer not showing DG

* fix test

* address feedback
  • Loading branch information
thelostone-mc authored May 14, 2024
1 parent 4c3c83f commit 1e888ad
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
2 changes: 2 additions & 0 deletions packages/data-layer/src/data.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,13 +501,15 @@ export type TimeFilter = {
lessThan?: string;
greaterThanOrEqualTo?: string;
lessThanOrEqualTo?: string;
isNull?: boolean;
};

export type TimeFilterVariables = {
applicationsStartTime?: TimeFilter;
applicationsEndTime?: TimeFilter;
donationsStartTime?: TimeFilter;
donationsEndTime?: TimeFilter;
or?: TimeFilterVariables[];
};

export type RoundsQueryVariables = {
Expand Down
2 changes: 1 addition & 1 deletion packages/grant-explorer/src/features/api/rounds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const useRounds = (
fetchSpamRounds(),
dataLayer.getRounds({
...variables,
first: 100,
first: 500,
chainIds,
}),
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -18,14 +19,17 @@ const ExploreRoundsPage = () => {
// Pass the filter from the search params and build the graphql query
const rounds = useFilterRounds(filter, getEnabledChains());

const publicRounds = useMemo(() => rounds.data?.filter(round => round.roundMetadata.roundType?.toLowerCase() !== "private"), [rounds]);
rounds.data = publicRounds;

const sectionTitle = getExplorerPageTitle(filter);

return (
<GradientLayout showWalletInteraction>
<LandingHero />

<LandingSection
title={`${sectionTitle} (${rounds.data?.length ?? 0})`}
title={`${sectionTitle} (${rounds?.data?.length ?? 0})`}
className="flex-wrap"
action={<RoundsFilter />}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1e888ad

Please sign in to comment.