Skip to content

Commit ac5dfab

Browse files
committed
fix: adjust page fields
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
1 parent 92e6536 commit ac5dfab

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

backend/src/api/public/v1/dev-stats/getAffiliations.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,31 @@ export async function getAffiliations(req: Request, res: Response): Promise<void
3333

3434
const lowercasedHandles = githubHandles.map((h) => h.toLowerCase())
3535

36-
const offset = (page - 1) * pageSize
37-
const pageHandles = lowercasedHandles.slice(offset, offset + pageSize)
36+
// Step 1: find all verified members across all handles
37+
const allMemberRows = await findMembersByGithubHandles(qx, lowercasedHandles)
3838

39-
// Step 1: find verified members by github handles
40-
const memberRows = await findMembersByGithubHandles(qx, pageHandles)
39+
const foundHandles = new Set(allMemberRows.map((r) => r.githubHandle.toLowerCase()))
40+
const notFound = lowercasedHandles.filter((h) => !foundHandles.has(h))
4141

42-
const foundHandles = new Set(memberRows.map((r) => r.githubHandle.toLowerCase()))
43-
const notFound = pageHandles.filter((h) => !foundHandles.has(h))
42+
const offset = (page - 1) * pageSize
43+
const pageMemberRows = allMemberRows.slice(offset, offset + pageSize)
4444

45-
if (memberRows.length === 0) {
45+
if (pageMemberRows.length === 0) {
4646
ok(res, {
4747
total: githubHandles.length,
48+
total_found: allMemberRows.length,
4849
page,
4950
pageSize,
50-
total_found: 0,
51+
page_found: 0,
5152
contributors: [],
5253
notFound,
5354
})
5455
return
5556
}
5657

57-
const memberIds = memberRows.map((r) => r.memberId)
58+
const memberIds = pageMemberRows.map((r) => r.memberId)
5859

59-
// Step 2: fetch verified emails
60+
// Step 2: fetch verified emails for current page
6061
const emailRows = await findVerifiedEmailsByMemberIds(qx, memberIds)
6162

6263
const emailsByMember = new Map<string, string[]>()
@@ -66,11 +67,11 @@ export async function getAffiliations(req: Request, res: Response): Promise<void
6667
emailsByMember.set(row.memberId, list)
6768
}
6869

69-
// Step 3: resolve affiliations (conflict resolution, gap-filling, selection priority)
70+
// Step 3: resolve affiliations for current page only
7071
const affiliationsByMember = await resolveAffiliationsByMemberIds(qx, memberIds)
7172

7273
// Step 4: build response
73-
const contributors = memberRows.map((member) => ({
74+
const contributors = pageMemberRows.map((member) => ({
7475
githubHandle: member.githubHandle,
7576
name: member.displayName,
7677
emails: emailsByMember.get(member.memberId) ?? [],
@@ -79,9 +80,10 @@ export async function getAffiliations(req: Request, res: Response): Promise<void
7980

8081
ok(res, {
8182
total: githubHandles.length,
83+
total_found: allMemberRows.length,
8284
page,
8385
pageSize,
84-
total_found: contributors.length,
86+
page_found: contributors.length,
8587
contributors,
8688
notFound,
8789
})

0 commit comments

Comments
 (0)