-
-
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
Merged
Merged
Changes from 17 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
c7078bf
feat: implement nestjs route returning mock data
Alphajax 5925549
feat: implement getting student summary from new api
Alphajax a749faf
refactor: fix eslint issue
Alphajax 3c9df1c
fix: fixed incorrect display of technical screening results on studenβ¦
Alphajax 75ddc97
refactor: remove unused code
Alphajax 7646422
refactor: remove redundant code
Alphajax 3de8682
refactor: fix linter issue
Alphajax 5729e23
Merge branch 'master' into rs-app-2435
Alphajax ee77148
fix: fix student summary api response type
Alphajax 8822c46
fix: throw not found error when student is not found
Alphajax 80b4128
fix: reactor if-else to ternary operation
Alphajax 5fe595d
refactor: rewrite database queries
Alphajax d39852a
refactor: make function getCurrentTaskScore more readable
Alphajax 22e5700
refactor:refactor getStudentSummary function return statement
Alphajax a1f731b
refactor: update course-student.service.ts imports not to use files fβ¦
Alphajax f65574d
Merge branch 'master' into rs-app-2435
Alphajax 985ef96
Merge branch 'master' into rs-app-2435
AlreadyBored a5661db
Merge branch 'master' into rs-app-2435
Alphajax 53f70bb
refactor: use StudentSummaryDto instead of (MentorBasic & MentorContact)
Alphajax 58a88ec
reafactor: remove unused code
Alphajax c03b0ad
refactor: avoid using 'me' to load student summary data
Alphajax ecb93ee
refactor: fix syntax error at comment
Alphajax 2281924
refactor: shorten return statement at getStageInterviewRating function
Alphajax 224c2b3
refactor: remove unused import
Alphajax 6fb76a6
refactor: avoid using unnecessary typecast
Alphajax 7cc7edf
refactor: add destructuring to convertToMentorBasic function
Alphajax 8d82bae
refactor: remove types duplication
Alphajax 8a0f92a
refactor: fix eslint error
Alphajax cc5fe5c
Merge branch 'master' into rs-app-2435
Alphajax 0895d6f
fix: fix merge issues
Alphajax cbd7f24
refactor: fix eslint issue
Alphajax 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 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 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 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
46 changes: 46 additions & 0 deletions
46
nestjs/src/courses/course-students/course-students.controller.ts
This file contains 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,46 @@ | ||
import { Controller, Get, NotFoundException, 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, | ||
) { | ||
const studentGithubId = githubId === 'me' ? req.user.githubId : githubId; | ||
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. To be honest, I don't like this usage of |
||
|
||
const student = await this.courseStudentService.getStudentByGithubId(courseId, studentGithubId); | ||
|
||
if (student === null) { | ||
throw new NotFoundException(`Student with GitHub id ${studentGithubId} not found`); | ||
} | ||
const [score, mentor] = await Promise.all([ | ||
this.courseStudentService.getStudentScore(student?.id), | ||
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, | ||
}); | ||
} | ||
} |
Oops, something went wrong.
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.
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.
As far as I can see,
StudentSummaryDto
is pretty same, let's avoid unnecessary typecasts/use really returned response type