-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
Changes from 8 commits
c7078bf
5925549
a749faf
3c9df1c
75ddc97
7646422
3de8682
5729e23
ee77148
8822c46
80b4128
5fe595d
d39852a
22e5700
a1f731b
f65574d
985ef96
a5661db
53f70bb
58a88ec
c03b0ad
ecb93ee
2281924
224c2b3
6fb76a6
7cc7edf
8d82bae
8a0f92a
cc5fe5c
0895d6f
cbd7f24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Let's split it a bit and make more readable
Suggested change
|
||||||||||||||
); | ||||||||||||||
const currentScore = isFinite(scoreRaw) ? scoreRaw : null; | ||||||||||||||
return currentScore; | ||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,48 @@ | ||||||
import { Controller, Get, Param, Req, UseGuards } from '@nestjs/common'; | ||||||
import { ApiBadRequestResponse, ApiForbiddenResponse, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger'; | ||||||
import { CurrentRequest, DefaultGuard } from '../../auth'; | ||||||
import { StudentSummaryDto } from './dto/student-summary.dto'; | ||||||
import { CourseStudentsService } from './course-students.service'; | ||||||
|
||||||
@Controller('courses/:courseId/students') | ||||||
@ApiTags('students') | ||||||
@UseGuards(DefaultGuard) | ||||||
export class CourseStudentsController { | ||||||
constructor(private courseStudentService: CourseStudentsService) {} | ||||||
|
||||||
@Get(':githubId/summary') | ||||||
@ApiForbiddenResponse() | ||||||
@ApiBadRequestResponse() | ||||||
@ApiOkResponse({ | ||||||
type: StudentSummaryDto, | ||||||
}) | ||||||
@ApiOperation({ operationId: 'getStudentSummary' }) | ||||||
public async getStudentSummary( | ||||||
@Param('courseId') courseId: number, | ||||||
@Param('githubId') githubId: string, | ||||||
@Req() req: CurrentRequest, | ||||||
) { | ||||||
let studentGithubId; | ||||||
if (githubId === 'me') { | ||||||
studentGithubId = req.user.githubId; | ||||||
} else { | ||||||
studentGithubId = githubId; | ||||||
} | ||||||
Alphajax marked this conversation as resolved.
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. e.g. do if (student == null) {
throw new NotFound(...)
} |
||||||
student?.mentorId ? await this.courseStudentService.getMentorWithContacts(student.mentorId) : null, | ||||||
]); | ||||||
|
||||||
return new StudentSummaryDto({ | ||||||
totalScore: score?.totalScore, | ||||||
results: score?.results, | ||||||
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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}); | ||||||
} | ||||||
} |
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?