-
-
Notifications
You must be signed in to change notification settings - Fork 206
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
feat:implement loading student summary using nestjs #2471
Conversation
nestjs/src/courses/course-students/course-students.controller.ts
Outdated
Show resolved
Hide resolved
const student = await this.courseStudentService.getStudentByGithubId(courseId, studentGithubId); | ||
|
||
const [score, mentor] = await Promise.all([ | ||
this.courseStudentService.getStudentScore(student?.id || 0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
student?.
if no user throw an error. Don't need to hide it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g. do
if (student == null) {
throw new NotFound(...)
}
@@ -0,0 +1,177 @@ | |||
import { User } from '@entities/user'; | |||
import { MentorBasic, StageInterviewFeedbackJson } from '@common/models'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not import from @common/
If you need a model, just copy to nest. We want to kill @common
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@valerydluski let's figure it out together
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@valerydluski thank you fo explanation
readonly mentorRepository: Repository<Mentor>, | ||
) {} | ||
|
||
studentQuery() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need it. Please just use studentRepository
where needed.
const record = await this.studentQuery() | ||
.innerJoin('student.user', 'user') | ||
.where('user.githubId = :githubId', { githubId }) | ||
.andWhere('student.courseId = :courseId', { courseId }) | ||
.getOne(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's rewrite it and do like:
this.studentRepository.findOne({
where: {
courseId,
user: { githubId },
},
relations: ['user']
})
client/src/services/course.ts
Outdated
const result = await this.axios.get(`/student/${githubId}/summary`); | ||
return result.data.data as StudentSummary; | ||
const result = await studentsApi.getStudentSummary(this.courseId, githubId); | ||
return result.data as unknown as StudentSummary; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curious, why do you need cast to unknown
? what's wrong with types?
@@ -304,7 +304,7 @@ export class CourseScheduleService { | |||
...(technicalScreeningResults | |||
.find(task => task.courseTaskId === courseTaskId) | |||
?.stageInterviewFeedbacks.map(feedback => JSON.parse(feedback.json)) | |||
.map((json: any) => json?.resume?.score ?? 0) ?? []), | |||
.map((json: any) => (json?.resume?.score || json?.steps?.decision?.values?.finalScore) ?? 0) ?? []), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's split it a bit and make more readable
.map((json: any) => (json?.resume?.score || json?.steps?.decision?.values?.finalScore) ?? 0) ?? []), | |
.map((json: any) => { | |
const resumeScore = json?.resume?.score; | |
const decisionScore = json?.steps?.decision?.values?.finalScore; | |
return resumeScore ?? decisionScore ?? 0; | |
}); |
rank: score?.rank, | ||
isActive: !student?.isExpelled && !student?.isFailed, | ||
mentor, | ||
repository: student?.repository || null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repository: student?.repository || null, | |
repository: student?.repository ?? null, |
const user = (mentor.user as User)!; | ||
return { | ||
isActive: !mentor.isExpelled, | ||
name: createName(user), | ||
id: mentor.id, | ||
githubId: user.githubId, | ||
students: mentor.students ? mentor.students.filter(s => !s.isExpelled && !s.isFailed).map(s => ({ id: s.id })) : [], | ||
cityName: user.cityName ?? '', | ||
countryName: user.countryName ?? '', | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type of mentor.user is User without this typecast
const user = (mentor.user as User)!; | |
return { | |
isActive: !mentor.isExpelled, | |
name: createName(user), | |
id: mentor.id, | |
githubId: user.githubId, | |
students: mentor.students ? mentor.students.filter(s => !s.isExpelled && !s.isFailed).map(s => ({ id: s.id })) : [], | |
cityName: user.cityName ?? '', | |
countryName: user.countryName ?? '', | |
}; | |
return { | |
isActive: !mentor.isExpelled, | |
name: createName(mentor.user), | |
id: mentor.id, | |
githubId: user.githubId, | |
students: mentor.students ? mentor.students.filter(s => !s.isExpelled && !s.isFailed).map(s => ({ id: s.id })) : [], | |
cityName: user.cityName ?? '', | |
countryName: user.countryName ?? '', | |
}; |
interface StageInterviewFeedback { | ||
common: { | ||
reason: 'haveITEducation' | 'doNotWorkInIT' | 'whatThisCourseAbout' | 'other' | null; | ||
reasonOther: string | null; | ||
whenStartCoding: number | null; | ||
schoolChallengesParticipaton: string | null; | ||
whereStudied: string | null; | ||
workExperience: string | null; | ||
otherAchievements: string | null; | ||
militaryService: 'served' | 'liable' | 'notLiable' | null; | ||
}; | ||
skills?: { | ||
[index: string]: any; | ||
htmlCss: { | ||
level: number | null; | ||
}; | ||
dataStructures: { | ||
array: number | null; | ||
list: number | null; | ||
stack: number | null; | ||
queue: number | null; | ||
tree: number | null; | ||
hashTable: number | null; | ||
heap: number | null; | ||
}; | ||
common: { | ||
binaryNumber: number | null; | ||
oop: number | null; | ||
bigONotation: number | null; | ||
sortingAndSearchAlgorithms: number | null; | ||
}; | ||
comment: string | null; | ||
}; | ||
programmingTask: { | ||
task: string | null; | ||
codeWritingLevel: number | null; | ||
resolved: number | null; | ||
comment: string | null; | ||
}; | ||
resume: { | ||
verdict: StageInterviewFeedbackVerdict; | ||
comment: string | null; | ||
score: number; | ||
}; | ||
} | ||
|
||
export type StageInterviewFeedbackVerdict = 'yes' | 'no' | 'noButGoodCandidate' | 'didNotDecideYet' | null; | ||
|
||
export type EnglishLevel = 'a0' | 'a1' | 'a1+' | 'a2' | 'a2+' | 'b1' | 'b1+' | 'b2' | 'b2+' | 'c1' | 'c1+' | 'c2'; | ||
|
||
export interface StageInterviewFeedbackJson extends StageInterviewFeedback { | ||
english: { | ||
levelStudentOpinion: EnglishLevel | null; | ||
levelMentorOpinion: EnglishLevel | null; | ||
whereAndWhenLearned: string | null; | ||
comment: string | null; | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have all these models in common/models
, why do you duplicate it here?
📦 Next.js Bundle Analysis for clientThis analysis was generated by the Next.js Bundle Analysis action. 🤖 Fifty-eight Pages Changed SizeThe following pages changed size from the code in this PR compared to its base branch:
DetailsOnly the gzipped size is provided here based on an expert tip. First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If Any third party scripts you have added directly to your app using the The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 5% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored. |
🟢 Add
deploy
label if you want to deploy this Pull Request to staging environment🧑⚖️ Pull Request Naming Convention
area:*
label(s)🤔 This is a ...
🔗 Related issue link
Describe the source of requirement, like related issue link.
💡 Background and solution
Describe the big picture of your changes here
☑️ Self Check before Merge