Skip to content

Commit

Permalink
Merge branch 'main' into indexer-builder-applications
Browse files Browse the repository at this point in the history
  • Loading branch information
codenamejason authored Feb 6, 2024
2 parents 41cc7ad + 6a0d6f2 commit 5768d99
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 29 deletions.
61 changes: 55 additions & 6 deletions packages/data-layer/src/backends/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ async function getProjectOwners(

const ROUNDS_QUERY = `
query GetRounds(
$first: Int,
$first: Int,
$orderBy: String,
$orderDirection: String,
$where: Round_filter,
Expand Down Expand Up @@ -390,8 +390,8 @@ export const getRounds = async (
},
{ graphqlEndpoints }: { graphqlEndpoints: Record<number, string> },
): Promise<RoundOverview[]> => {
let rounds: RoundOverview[] = await Promise.all(
params.chainIds.flatMap(async (chainId) => {
let roundsPromise: Promise<RoundOverview[]>[] = params.chainIds.flatMap(
async (chainId) => {
const round = await graphql_fetch(
ROUNDS_QUERY,
graphqlEndpoints[chainId],
Expand All @@ -403,15 +403,28 @@ export const getRounds = async (
chainId,
})) ?? []
);
}),
},
);
rounds = rounds.flat();

let spamRounds: SpamRoundsMaps = {};
try {
spamRounds = await fetchSpamRounds();
} catch (e) {
console.error("Failed to fetch spam rounds", e);
}

let rounds = (await Promise.all(roundsPromise)).flat();
rounds = cleanRoundData(rounds);
rounds = sortRounds(rounds, params);
rounds = rounds.filter((round) => {
const isSpam = spamRounds[round.chainId]?.[round.id.toLowerCase()] === true;
return !isSpam;
});

return rounds;
};

/*
/*
Some timestamps are in milliseconds and others in overflowed values (115792089237316195423570985008687907853269984665640564039457584007913129639935)
See this query: https://api.thegraph.com/subgraphs/name/gitcoinco/grants-round-optimism-mainnet/graphql?query=query+%7B%0A+++rounds%28first%3A+3%2C%0A++++++orderBy%3A+roundEndTime%2C%0A++++++orderDirection%3A+asc%0A++++%29+%7B%0A++++++id%0A++++++roundEndTime%0A+++++%0A++++%7D%0A%7D
*/
Expand Down Expand Up @@ -482,3 +495,39 @@ export const sortRounds = (
compareFn(a, b) ? dir[orderDirection] : -dir[orderDirection],
);
};

type SpamRoundsMaps = {
[chainId: number]: {
[roundId: string]: boolean;
};
};

// Temporary round curation to avoid spam
async function fetchSpamRounds(): Promise<SpamRoundsMaps> {
const spam: SpamRoundsMaps = {};

const csvContent = await fetch(
"https://docs.google.com/spreadsheets/d/10jekVhMuFg6IQ0sYAN_dxh_U-OxU7EAuGMNvTtlpraM/export?format=tsv",
).then((res) => res.text());

const rows = csvContent.split("\n");
rows
// skip the header row
.slice(1)
.forEach((line) => {
const columns = line.split("\t");
const url = columns[1];
// extract chainId and roundId
const regex =
/https:\/\/explorer\.gitcoin\.co\/#\/round\/(\d+)\/([0-9a-fA-Fx]+)/;
const match = url.match(regex);
if (match) {
const chainId = parseInt(match[1]);
const roundId = match[2].toLowerCase();
spam[chainId] ||= {};
spam[chainId][roundId] = true;
}
});

return spam;
}
53 changes: 32 additions & 21 deletions packages/grant-explorer/src/features/round/ViewProjectDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ export default function ViewProjectDetails() {
onChange={handleTabChange}
tabs={projectDetailsTabs.map((tab) => tab.name)}
/>
<div>{projectDetailsTabs[selectedTab].content}</div>
<div className="[&_a]:underline">
{projectDetailsTabs[selectedTab].content}
</div>
</div>
</div>
</DefaultLayout>
Expand Down Expand Up @@ -309,23 +311,29 @@ function ProjectLinks({ project }: { project?: Project }) {
<ProjectLink url={website} icon={GlobeIcon}>
{website}
</ProjectLink>
<ProjectLink
url={projectTwitter}
icon={TwitterIcon}
isVerified={verified.data?.twitter}
>
{projectTwitter}
</ProjectLink>
<ProjectLink
url={projectGithub}
icon={GithubIcon}
isVerified={verified.data?.github}
>
{projectGithub}
</ProjectLink>
<ProjectLink url={userGithub} icon={GithubIcon}>
{userGithub}
</ProjectLink>
{projectTwitter !== undefined && (
<ProjectLink
url={`https://twitter.com/${projectTwitter}`}
icon={TwitterIcon}
isVerified={verified.data?.twitter}
>
{projectTwitter}
</ProjectLink>
)}
{projectGithub !== undefined && (
<ProjectLink
url={`https://github.com/${projectGithub}`}
icon={GithubIcon}
isVerified={verified.data?.github}
>
{projectGithub}
</ProjectLink>
)}
{userGithub !== undefined && (
<ProjectLink url={`https://github.com/${userGithub}`} icon={GithubIcon}>
{userGithub}
</ProjectLink>
)}
</div>
);
}
Expand Down Expand Up @@ -412,9 +420,12 @@ function ApplicationFormAnswers(props: {
className="text-md prose prose-h1:text-lg prose-h2:text-base prose-h3:text-base prose-a:text-blue-600"
></p>
) : (
<p className="text-base text-black">
{answerText.replace(/\n/g, "<br/>")}
</p>
<p
className="text-base text-black"
dangerouslySetInnerHTML={{
__html: renderToHTML(answerText.replace(/\n/g, "\n\n")),
}}
></p>
)}
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/grant-explorer/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&display=swap');

@font-face {
font-family: "Modern Era Regular";
font-family: "Modern Era";
font-weight: 400;
src: local("ModernEraRegular"),
url("../public/modern-era-regular.otf") format('opentype');
Expand All @@ -16,7 +16,7 @@
}

@font-face {
font-family: "Modern Era";
font-family: "Modern Era Bold";
font-weight: 600;
src: local("ModernEraBold"),
url("../public/modern-era-bold.otf") format('opentype');
Expand Down

0 comments on commit 5768d99

Please sign in to comment.