[INTW26] Build queries for review homepage - #131
Conversation
…nto INTW26-review-homepage-queries
…nto INTW26-review-homepage-queries
|
|
||
| @BelongsTo(() => Applicant, "applicantId") | ||
| applicant?: NonAttribute<Applicant>; | ||
| applicant!: NonAttribute<Applicant>; |
There was a problem hiding this comment.
These type assertions are added to better use the models and resolve errors with type checking. This is also logically correct, a model that belongs to another model should never be null/undefined
There was a problem hiding this comment.
Nice, finally a good usage of the non-null assertion
| const assignedDelegations = await InterviewDelegation.findAll({ | ||
| where: { interviewerId: userId }, | ||
| include: [ | ||
| { | ||
| model: InterviewedApplicantRecord, | ||
| attributes: ["applicantRecordId", "status"], | ||
| include: [ | ||
| { | ||
| model: ApplicantRecord, | ||
| include: [ | ||
| { | ||
| model: Applicant, | ||
| attributes: ["firstName", "lastName"], | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| }); |
There was a problem hiding this comment.
I was reading up on some best practices for sequelize, I think this pattern is more clear and uses types better than the existing pattern. Hoping to adopt this during the migration.
| attributes: ["groupId"], | ||
| }); | ||
|
|
||
| // dedupe groupIds, although each groupId should have a unique set of interviewers, the database design does not guarantee this. |
There was a problem hiding this comment.
Can we not have a unique constraint at the DB lvl?
There was a problem hiding this comment.
i don't think so, so basically how it works is the following:
InterviewGroups and InterviewDelegation (a delegation is defined by one interviewer and applicant)
Each InterviewDelegation belongs to an InterviewGroup (interview delegation has FK groupId), but an InterviewGroup should have multiple delegations.
For example we have interview group 1.
We have interview delegation A1, which consists of person A and candidate X and belongs to interview group 1.
We have interview delegation B1, which consists of person B and candidate X and belongs to interview group 1.
Nothing here allows us to guarantee uniqueness on the interviewer...
| // dedupe groupIds, although each groupId should have a unique set of interviewers, the database design does not guarantee this. | ||
| const groupIds = [...new Set(userGroupRows.map((row) => row.groupId))]; | ||
| if (groupIds.length === 0) { | ||
| return []; |
There was a problem hiding this comment.
lets move this check above the groupIds so we have something like the following....
if (userGroupRows.length === 0){
return [];
}
// then we find the groupIds
const groupIds - [...new Set(userGroupRows.map((rows) => row.groupId))];|
|
||
| @BelongsTo(() => Applicant, "applicantId") | ||
| applicant?: NonAttribute<Applicant>; | ||
| applicant!: NonAttribute<Applicant>; |
There was a problem hiding this comment.
Nice, finally a good usage of the non-null assertion
Build queries for review homepage
Implementation description
Steps to test
AR_ID_1andAR_ID_2with two ids from yourapplicant_recordstableThe result should contain the applicant(s) you chose previously.
The result should contain information about the interviewers each user is paired with.
What should reviewers focus on?
Checklist
](https://www.notion.so/uwblueprintexecs/Build-Queries-for-Review-Homepage-32310f3fb1dc809bbb45f3fc9ce7d569?source=copy_link)