Skip to content

Commit

Permalink
Merge pull request #147 from Giveth/add-rounf-filter
Browse files Browse the repository at this point in the history
add-round-filter
  • Loading branch information
MohammadPCh authored Nov 9, 2024
2 parents af99fa1 + 1716fc5 commit d7c58fa
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/server-extension/project-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class ProjectResolver {
@Arg("organizations", () => [String], { nullable: true })
organizations?: string[],
@Arg("sources", () => [String], { nullable: true }) sources?: string[],
@Arg("rfRounds", () => [Int], { nullable: true }) rfRounds?: number[],
@Arg("sortBy", () => String, { nullable: true })
sortBy: EProjectSort = EProjectSort.HIGHEST_VOUCH_COUNT,
@Arg("limit", () => Int, { nullable: true }) limit: number = 10,
Expand Down Expand Up @@ -44,6 +45,13 @@ export class ProjectResolver {
paramIndex++;
}

// Add rfRounds filter if rfRounds are provided
if (rfRounds && rfRounds.length > 0) {
conditions.push(`project.rf_rounds && $${paramIndex}::int[]`);
parameters.push(rfRounds);
paramIndex++;
}

// Add vouch/flag condition
conditions.push(`organisation_project.vouch = $${paramIndex}`);
parameters.push(vouchValue);
Expand All @@ -65,7 +73,7 @@ export class ProjectResolver {
// Construct the final query
const query = `
SELECT
project.id,
project.id,
SUM(organisation_project.count) AS total_count
FROM
project
Expand Down

0 comments on commit d7c58fa

Please sign in to comment.