-
Notifications
You must be signed in to change notification settings - Fork 1
[INTF25] Adds applicant record and reviews query #81
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
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
11141ce
query for applicant record and review
gavxue 3d65136
Merge branch 'main' of https://github.com/uwblueprint/website-bp-be i…
gavxue a00b1cb
created helper
gavxue 4006133
Merge branch 'main' of https://github.com/uwblueprint/website-bp-be i…
gavxue 6a1062f
Merge branch 'main' of https://github.com/uwblueprint/website-bp-be i…
gavxue 228bf67
minor fixes to types and allowing null values
gavxue 963b4dd
linting fix
gavxue 2ce98b2
Merge branch 'main' of https://github.com/uwblueprint/website-bp-be i…
gavxue 1b2121f
Merge branch 'main' of https://github.com/uwblueprint/website-bp-be i…
gavxue 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
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
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
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 |
|---|---|---|
| @@ -1,4 +1,8 @@ | ||
| import { PositionTitle, ReviewDashboardRowDTO } from "../../types"; | ||
| import { | ||
| PositionTitle, | ||
| ReviewDashboardRowDTO, | ||
| ReviewDashboardSidePanelDTO, | ||
| } from "../../types"; | ||
| import IReviewDashboardService from "../interfaces/IReviewDashboardService"; | ||
| import { getErrorMessage } from "../../utilities/errorUtils"; | ||
| import logger from "../../utilities/logger"; | ||
|
|
@@ -22,6 +26,26 @@ function toDTO(model: ApplicantRecord): ReviewDashboardRowDTO { | |
| }; | ||
| } | ||
|
|
||
| function toSidePanelDTO(model: ApplicantRecord): ReviewDashboardSidePanelDTO { | ||
| const reviewDetails = | ||
| model.reviewedApplicantRecords?.map((reviewRecord) => ({ | ||
| reviewerFirstName: reviewRecord.user?.first_name || "", | ||
| reviewerLastName: reviewRecord.user?.last_name || "", | ||
| review: reviewRecord.review, | ||
| })) || []; | ||
|
|
||
| return { | ||
| firstName: model.applicant!.firstName, | ||
| lastName: model.applicant!.lastName, | ||
| positionTitle: model.position as PositionTitle, | ||
| program: model.applicant!.program, | ||
| resumeUrl: model.applicant!.resumeUrl, | ||
| applicationStatus: model.status, | ||
| skillCategory: model.skillCategory, | ||
| reviewDetails, | ||
| }; | ||
| } | ||
|
|
||
| class ReviewDashboardService implements IReviewDashboardService { | ||
| /* eslint-disable class-methods-use-this */ | ||
| async getReviewDashboard( | ||
|
|
@@ -72,6 +96,47 @@ class ReviewDashboardService implements IReviewDashboardService { | |
| throw error; | ||
| } | ||
| } | ||
|
|
||
| async getReviewDashboardSidePanel( | ||
| applicantId: string, | ||
| ): Promise<ReviewDashboardSidePanelDTO> { | ||
| try { | ||
| const applicantRecord: ApplicantRecord | null = | ||
| await ApplicantRecord.findOne({ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🥹 looks familiar |
||
| where: { applicantId }, | ||
| attributes: { exclude: ["createdAt", "updatedAt"] }, | ||
| include: [ | ||
| { | ||
| attributes: { exclude: ["createdAt", "updatedAt"] }, | ||
| association: "reviewedApplicantRecords", | ||
| include: [ | ||
| { | ||
| attributes: { exclude: ["createdAt", "updatedAt"] }, | ||
| association: "user", | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| attributes: { exclude: ["createdAt", "updatedAt"] }, | ||
| association: "applicant", | ||
| }, | ||
| ], | ||
| }); | ||
|
|
||
| if (!applicantRecord || !applicantRecord.applicant) { | ||
| throw new Error(`Applicant with ID ${applicantId} not found`); | ||
| } | ||
|
|
||
| return toSidePanelDTO(applicantRecord); | ||
| } catch (error: unknown) { | ||
| Logger.error( | ||
| `Failed to get review dashboard side panel for applicant ${applicantId}. Reason = ${getErrorMessage( | ||
| error, | ||
| )}`, | ||
| ); | ||
| throw error; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| export default ReviewDashboardService; | ||
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
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.