-
Notifications
You must be signed in to change notification settings - Fork 734
feat: single lookup (CM-1060) #3964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+42
−0
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
89a585e
feat: add static api key middleware for dev stats
ulemons 0f4e5ca
fix: lint
ulemons 14dcd89
fix: remove local secret
ulemons f952c77
fix: use db oriented api keys
ulemons 16507d9
fix: remove useless env var
ulemons 7581772
fix: lint
ulemons c696a00
fix: review
ulemons ee921b8
feat: add query layer
ulemons dd59ec7
feat: add filtering on query layer
ulemons a7d9a51
feat: refactor in dal
ulemons 866cee2
feat: add affiliations
ulemons 97c0e11
feat: adding logs
ulemons fe34c2d
fix: lint
ulemons 4463354
fix: lint
ulemons 6267224
fix: created at error
ulemons c90150c
fix: createdAt as date
ulemons af22bdd
feat: adding logs
ulemons 335387e
refactor: simplify buildTimeline
ulemons 856b001
fix: lint
ulemons 9d0aee8
fix: remove comments
ulemons 1d11072
fix: change logging
ulemons 47de513
refactor: create dal for affiliations
ulemons a764ba2
fix: lint
ulemons b18ccb0
refactor: export affiliation on dal
ulemons fc4e99c
fix: test not joining for member count
ulemons 42eee93
fix: refactor v1Router
ulemons 468467b
fix: add 404 error
ulemons ab79811
fix: add 404 error in public router
ulemons 82a1b56
fix: revert not found inside the routher
ulemons c3660f2
feat: use join instead of in
ulemons 3911bdb
feat: revert to memberOrganizations
ulemons 1ded750
feat: remove useless logs
ulemons 480a8b5
fix: use common blacklist variable
ulemons ac9ed84
feat: merge
ulemons 90a1fd0
feat: add single lookup
ulemons 4977ae7
fix: remove useless dal
ulemons 35168c4
fix: remove duplicated not found
ulemons File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
backend/src/api/public/v1/affiliations/getAffiliationByHandle.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import type { Request, Response } from 'express' | ||
|
|
||
| import { NotFoundError } from '@crowd/common' | ||
| import { | ||
| findMembersByGithubHandles, | ||
| findVerifiedEmailsByMemberIds, | ||
| optionsQx, | ||
| resolveAffiliationsByMemberIds, | ||
| } from '@crowd/data-access-layer' | ||
|
|
||
| import { ok } from '@/utils/api' | ||
|
|
||
| export async function getAffiliationByHandle(req: Request, res: Response): Promise<void> { | ||
| const handle = req.params.githubHandle.toLowerCase() | ||
| const qx = optionsQx(req) | ||
|
|
||
| const members = await findMembersByGithubHandles(qx, [handle]) | ||
| if (members.length === 0) { | ||
| throw new NotFoundError(`No LFX profile found for GitHub login '${req.params.githubHandle}'.`) | ||
ulemons marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| const member = members[0] | ||
ulemons marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const memberIds = [member.memberId] | ||
|
|
||
| const [emailRows, affiliationsByMember] = await Promise.all([ | ||
| findVerifiedEmailsByMemberIds(qx, memberIds), | ||
| resolveAffiliationsByMemberIds(qx, memberIds), | ||
| ]) | ||
|
|
||
| ok(res, { | ||
| githubHandle: member.githubHandle, | ||
| name: member.displayName, | ||
| emails: emailRows.map((r) => r.email), | ||
| affiliations: affiliationsByMember.get(member.memberId) ?? [], | ||
| }) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.