diff --git a/src/server-extension/organization-resolver.ts b/src/server-extension/organization-resolver.ts index 29c2bf1..bd27536 100644 --- a/src/server-extension/organization-resolver.ts +++ b/src/server-extension/organization-resolver.ts @@ -116,7 +116,8 @@ export class OrganisationResolver { const query = ` SELECT attestor_organisation.attestor_id AS attestor_id, - COUNT(*) AS total_count + COUNT(*) AS total_count, + SUM(CASE WHEN project_attestation.comment IS NOT NULL AND project_attestation.comment != '' THEN 1 ELSE 0 END) AS count_with_comments FROM project_attestation JOIN attestor_organisation @@ -139,18 +140,24 @@ export class OrganisationResolver { const result = await manager.query(query, params); let totalVouches = 0; + let totalWithComments = 0; const vouchCountByUser: VouchCountByUser[] = result.map((row: any) => { const totalCount = Number(row.total_count); + const countWithComments = Number(row.count_with_comments); + totalVouches += totalCount; + totalWithComments += countWithComments; return { attestorId: row.attestor_id, totalCount, + countWithComments, }; }); return { totalVouches, + totalWithComments, vouchCountByUser, }; } catch (error: any) { diff --git a/src/server-extension/types.ts b/src/server-extension/types.ts index 1c76316..a1c332b 100644 --- a/src/server-extension/types.ts +++ b/src/server-extension/types.ts @@ -46,6 +46,9 @@ export class VouchCountByUser { @Field(() => Int) totalCount: number = 0; + + @Field(() => Int) + countWithComments: number = 0; } @ObjectType() @@ -53,6 +56,9 @@ export class VouchCountByUserResult { @Field(() => Int) totalVouches: number = 0; + @Field(() => Int) + totalWithComments: number = 0; + @Field(() => [VouchCountByUser]) vouchCountByUser: VouchCountByUser[] = []; }