From a4a6e803accac73dc3ed076a035dd7ae11754af2 Mon Sep 17 00:00:00 2001 From: Cherik Date: Fri, 15 Nov 2024 12:33:31 +0330 Subject: [PATCH 1/3] add rfRounds to ProjectsSortedByVouchOrFlagType --- src/server-extension/types.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/server-extension/types.ts b/src/server-extension/types.ts index a1c332b..20c10f1 100644 --- a/src/server-extension/types.ts +++ b/src/server-extension/types.ts @@ -10,6 +10,9 @@ export enum EProjectSort { export class ProjectsSortedByVouchOrFlagType { @Field(() => ID) id!: string; + + @Field(() => [Int], { nullable: true }) + rfRounds: number[] = []; } @ObjectType() From 8ab203c4008c1c9cdb9ebc6a8e67502e7772f8a0 Mon Sep 17 00:00:00 2001 From: Cherik Date: Fri, 15 Nov 2024 12:33:50 +0330 Subject: [PATCH 2/3] return rfRounds --- src/server-extension/project-resolver.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/server-extension/project-resolver.ts b/src/server-extension/project-resolver.ts index 13b9fca..9ef9d70 100644 --- a/src/server-extension/project-resolver.ts +++ b/src/server-extension/project-resolver.ts @@ -73,6 +73,7 @@ export class ProjectResolver { const query = ` SELECT project.id, + project.rf_rounds, SUM(organisation_project.count) AS total_count FROM project @@ -90,8 +91,12 @@ export class ProjectResolver { // Execute the query with parameters const rawProjects = await manager.query(query, parameters); + const res = rawProjects.map((rawProject: any) => ({ + rfRounds: rawProject.rf_rounds, + ...rawProject, + })); - return rawProjects; + return res; } catch (error) { console.error("Error fetching and sorting projects:", error); throw new Error("Failed to fetch and sort projects"); From dcee49f3fa33e8f97a82848b964b782f88e3bd03 Mon Sep 17 00:00:00 2001 From: Cherik Date: Fri, 15 Nov 2024 12:41:45 +0330 Subject: [PATCH 3/3] handle types --- src/server-extension/project-resolver.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/server-extension/project-resolver.ts b/src/server-extension/project-resolver.ts index 9ef9d70..29c5ae6 100644 --- a/src/server-extension/project-resolver.ts +++ b/src/server-extension/project-resolver.ts @@ -91,12 +91,16 @@ export class ProjectResolver { // Execute the query with parameters const rawProjects = await manager.query(query, parameters); - const res = rawProjects.map((rawProject: any) => ({ - rfRounds: rawProject.rf_rounds, - ...rawProject, - })); - - return res; + 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");