Skip to content

Commit

Permalink
check base cluster for pid, check group for base cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmegill committed Feb 27, 2025
1 parent 56ed5c2 commit 4f178b0
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions server/src/routes/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,35 @@ export async function sendParticipantVotesSummary(zid: number, res: Response) {
const pca = await getPca(zid);
const groupClusters: { id: number; members: number[] }[] | undefined =
pca?.asPOJO["group-clusters"];

const baseClusters: { id: number; members: number[] }[] | undefined =
pca?.asPOJO["base-clusters"];

function getGroupId(pid: number) {
if (groupClusters) {
if (!baseClusters || !groupClusters) {
return undefined;
}

// First find which base cluster contains this participant
const baseClusterIds = baseClusters.id;
const baseClusterMembers = baseClusters.members;
let baseClusterId = -1;
for (let i = 0; i < baseClusterIds.length; i++) {
if (baseClusterMembers[i].includes(pid)) {
baseClusterId = baseClusterIds[i];
break;
}
}

// If we found a base cluster, check which group contains it
if (baseClusterId !== -1) {
for (const group of groupClusters) {
if (group.members.includes(pid)) {
if (group.members.includes(baseClusterId)) {
return group.id;
}
}
}

return undefined;
}

Expand Down

0 comments on commit 4f178b0

Please sign in to comment.