Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filters by goerli and alfajores #1108

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/entities/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export enum FilterField {
AcceptFundOnPolygon = 'acceptFundOnPolygon',
AcceptFundOnCelo = 'acceptFundOnCelo',
AcceptFundOnOptimism = 'acceptFundOnOptimism',
AcceptFundOnGoerli = 'acceptFundOnGoerli',
AcceptFundOnAlfajores = 'acceptFundOnAlfajores',
GivingBlock = 'fromGivingBlock',
BoostedWithGivPower = 'boostedWithGivPower',
ActiveQfRound = 'ActiveQfRound',
Expand Down
70 changes: 70 additions & 0 deletions src/resolvers/projectResolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,76 @@ function allProjectsTestCases() {
);
});

it('should return projects, filter by accept donation on GOERLI', async () => {
const savedProject = await saveProjectDirectlyToDb({
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
});
const optimismAddress = (await findProjectRecipientAddressByNetworkId({
projectId: savedProject.id,
networkId: NETWORK_IDS.GOERLI,
})) as ProjectAddress;
optimismAddress.isRecipient = true;
await optimismAddress.save();
const result = await axios.post(graphqlUrl, {
query: fetchMultiFilterAllProjectsQuery,
variables: {
filters: ['AcceptFundOnGoerli'],
sortingBy: SortingField.Newest,
},
});
result.data.data.allProjects.projects.forEach(project => {
assert.isOk(
project.addresses.find(
address =>
address.isRecipient === true &&
address.networkId === NETWORK_IDS.GOERLI,
),
);
});
assert.isOk(
result.data.data.allProjects.projects.find(
project => Number(project.id) === Number(savedProject.id),
),
);
});

it('should return projects, filter by accept donation on ALFAJORES', async () => {
const savedProject = await saveProjectDirectlyToDb({
...createProjectData(),
title: String(new Date().getTime()),
slug: String(new Date().getTime()),
});
const optimismAddress = (await findProjectRecipientAddressByNetworkId({
projectId: savedProject.id,
networkId: NETWORK_IDS.CELO_ALFAJORES,
})) as ProjectAddress;
optimismAddress.isRecipient = true;
await optimismAddress.save();
const result = await axios.post(graphqlUrl, {
query: fetchMultiFilterAllProjectsQuery,
variables: {
filters: ['AcceptFundOnAlfajores'],
sortingBy: SortingField.Newest,
},
});
result.data.data.allProjects.projects.forEach(project => {
assert.isOk(
project.addresses.find(
address =>
address.isRecipient === true &&
address.networkId === NETWORK_IDS.CELO_ALFAJORES,
),
);
});
assert.isOk(
result.data.data.allProjects.projects.find(
project => Number(project.id) === Number(savedProject.id),
),
);
});

it('should return projects, filter by accept donation on optimism', async () => {
const savedProject = await saveProjectDirectlyToDb({
...createProjectData(),
Expand Down
24 changes: 22 additions & 2 deletions src/resolvers/projectResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,9 @@ export class ProjectResolver {
(filter === FilterField.AcceptFundOnGnosis ||
filter === FilterField.AcceptFundOnCelo ||
filter === FilterField.AcceptFundOnPolygon ||
filter === FilterField.AcceptFundOnOptimism) &&
filter === FilterField.AcceptFundOnOptimism ||
filter === FilterField.AcceptFundOnGoerli ||
filter === FilterField.AcceptFundOnAlfajores) &&
filterValue
) {
const networkIds: number[] = [];
Expand All @@ -512,6 +514,14 @@ export class ProjectResolver {
networkIds.push(NETWORK_IDS.POLYGON);
}

if (filter === 'acceptFundOnGoerli') {
networkIds.push(NETWORK_IDS.GOERLI);
}

if (filter === 'acceptFundOnAlfajores') {
networkIds.push(NETWORK_IDS.CELO_ALFAJORES);
}

if (filter === 'acceptFundOnOptimism') {
networkIds.push(NETWORK_IDS.OPTIMISTIC);
}
Expand Down Expand Up @@ -569,7 +579,9 @@ export class ProjectResolver {
filter === FilterField.AcceptFundOnCelo ||
filter === FilterField.AcceptFundOnPolygon ||
filter === FilterField.AcceptFundOnMainnet ||
filter === FilterField.AcceptFundOnOptimism) &&
filter === FilterField.AcceptFundOnOptimism ||
filter === FilterField.AcceptFundOnGoerli ||
filter === FilterField.AcceptFundOnAlfajores) &&
filter
) {
const networkIds: number[] = [];
Expand All @@ -592,6 +604,14 @@ export class ProjectResolver {
networkIds.push(NETWORK_IDS.OPTIMISTIC);
}

if (filter === FilterField.AcceptFundOnGoerli) {
networkIds.push(NETWORK_IDS.GOERLI);
}

if (filter === FilterField.AcceptFundOnAlfajores) {
networkIds.push(NETWORK_IDS.CELO_ALFAJORES);
}

return subQuery.andWhere(
`EXISTS (
SELECT *
Expand Down
Loading