Skip to content

Commit

Permalink
Merge pull request #150 from Giveth/change-query-to-return-rounds
Browse files Browse the repository at this point in the history
Change query to return rounds
  • Loading branch information
MohammadPCh authored Nov 15, 2024
2 parents f61af4f + dcee49f commit ca24bf3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/server-extension/project-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export class ProjectResolver {
const query = `
SELECT
project.id,
project.rf_rounds,
SUM(organisation_project.count) AS total_count
FROM
project
Expand All @@ -90,8 +91,16 @@ export class ProjectResolver {

// Execute the query with parameters
const rawProjects = await manager.query(query, parameters);

return rawProjects;
return rawProjects.map(
(rawProject: {
id: string;
rf_rounds: number[] | null;
total_count: number;
}) => ({
...rawProject,
rfRounds: rawProject.rf_rounds,
})
);
} catch (error) {
console.error("Error fetching and sorting projects:", error);
throw new Error("Failed to fetch and sort projects");
Expand Down
3 changes: 3 additions & 0 deletions src/server-extension/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export enum EProjectSort {
export class ProjectsSortedByVouchOrFlagType {
@Field(() => ID)
id!: string;

@Field(() => [Int], { nullable: true })
rfRounds: number[] = [];
}

@ObjectType()
Expand Down

0 comments on commit ca24bf3

Please sign in to comment.