Skip to content
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 31 commits into from
Jul 11, 2024
Merged

Conversation

Alphajax
Copy link
Contributor

@Alphajax Alphajax commented Apr 30, 2024

🟢 Add deploy label if you want to deploy this Pull Request to staging environment

🧑‍⚖️ Pull Request Naming Convention

  • Title should follow Conventional Commits
  • Do not put issue id in title
  • Do not put WIP in title. Use Draft PR functionality
  • Consider to add area:* label(s)
  • I followed naming convention rules

🤔 This is a ...

  • New feature
  • Bug fix
  • Performance optimization
  • Refactoring
  • Test Case
  • Documentation update
  • Other

🔗 Related issue link

Describe the source of requirement, like related issue link.

💡 Background and solution

Describe the big picture of your changes here

  • implement new api in nestjs backend which clones functionality of getStudentSummary route from server
  • fix incorrect tech check point view on profile page

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Database migration is added or not needed
  • Documentation is updated/provided or not needed
  • Changes are tested locally

@Alphajax Alphajax added the 🚧 in-progress Work In Progress label Apr 30, 2024
@Alphajax Alphajax removed the 🚧 in-progress Work In Progress label Apr 30, 2024
const student = await this.courseStudentService.getStudentByGithubId(courseId, studentGithubId);

const [score, mentor] = await Promise.all([
this.courseStudentService.getStudentScore(student?.id || 0),
Copy link
Member

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.

Copy link
Member

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';
Copy link
Member

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

Copy link
Contributor Author

@Alphajax Alphajax Apr 30, 2024

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Alphajax When you asked me, I thought you meant Entity (example). We can confidently move the rest to Nest. I apologize for the misunderstanding, my bad.

Copy link
Contributor Author

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() {
Copy link
Member

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.

Comment on lines 31 to 35
const record = await this.studentQuery()
.innerJoin('student.user', 'user')
.where('user.githubId = :githubId', { githubId })
.andWhere('student.courseId = :courseId', { courseId })
.getOne();
Copy link
Member

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']
  })

@rolling-scopes rolling-scopes deleted a comment from github-actions bot Apr 30, 2024
@rolling-scopes rolling-scopes deleted a comment from github-actions bot Apr 30, 2024
@rolling-scopes rolling-scopes deleted a comment from github-actions bot Apr 30, 2024
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;
Copy link
Member

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?

@rolling-scopes rolling-scopes deleted a comment from github-actions bot Apr 30, 2024
@@ -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) ?? []),
Copy link
Contributor

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

Suggested change
.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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
repository: student?.repository || null,
repository: student?.repository ?? null,

@rolling-scopes rolling-scopes deleted a comment from github-actions bot May 6, 2024
@rolling-scopes rolling-scopes deleted a comment from github-actions bot May 6, 2024
Comment on lines 158 to 167
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 ?? '',
};
Copy link
Contributor

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

Suggested change
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 ?? '',
};

Comment on lines 1 to 58
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;
};
}
Copy link
Contributor

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?

@rolling-scopes rolling-scopes deleted a comment from github-actions bot Jun 9, 2024
@rolling-scopes rolling-scopes deleted a comment from github-actions bot Jun 9, 2024
@rolling-scopes rolling-scopes deleted a comment from github-actions bot Jun 9, 2024
@rolling-scopes rolling-scopes deleted a comment from github-actions bot Jun 9, 2024
@rolling-scopes rolling-scopes deleted a comment from github-actions bot Jun 9, 2024
@rolling-scopes rolling-scopes deleted a comment from github-actions bot Jun 9, 2024
@rolling-scopes rolling-scopes deleted a comment from github-actions bot Jun 9, 2024
@rolling-scopes rolling-scopes deleted a comment from github-actions bot Jun 9, 2024
@rolling-scopes rolling-scopes deleted a comment from github-actions bot Jun 9, 2024
@rolling-scopes rolling-scopes deleted a comment from github-actions bot Jul 11, 2024
Copy link

📦 Next.js Bundle Analysis for client

This analysis was generated by the Next.js Bundle Analysis action. 🤖

Fifty-eight Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (500 KB)
/ 295.07 KB 406.08 KB 81.22% (🟡 +0.01%)
/404 229.73 KB 340.75 KB 68.15% (🟡 +0.01%)
/admin/courses 390.75 KB 501.77 KB 100.35% (🟡 +0.02%)
/admin/disciplines 335.73 KB 446.75 KB 89.35% (🟡 +0.01%)
/admin/discord-server 362.49 KB 473.5 KB 94.70% (🟡 +0.02%)
/admin/events 363.14 KB 474.16 KB 94.83% (🟡 +0.02%)
/admin/mentor-registry 388.35 KB 499.36 KB 99.87% (🟡 +0.02%)
/admin/notifications 403.03 KB 514.04 KB 102.81% (🟡 +0.01%)
/admin/prompts 343.02 KB 454.03 KB 90.81% (🟡 +0.01%)
/admin/registrations 335.46 KB 446.47 KB 89.29% (🟡 +0.02%)
/admin/students 351.25 KB 462.26 KB 92.45% (🟡 +0.02%)
/admin/tasks 448.99 KB 560.01 KB 112.00% (🟡 +0.02%)
/admin/user-group 387.46 KB 498.48 KB 99.70% (🟡 +0.01%)
/admin/users 277.71 KB 388.72 KB 77.74% (🟡 +0.02%)
/applicants 318.34 KB 429.36 KB 85.87% (🟡 +0.02%)
/course/admin/certified-students 175.58 KB 286.6 KB 57.32% (🟡 +0.01%)
/course/admin/cross-check-table 476.46 KB 587.48 KB 117.50% (🟡 +0.01%)
/course/admin/events 445.82 KB 556.84 KB 111.37% (🟡 +0.01%)
/course/admin/interviews 386.4 KB 497.42 KB 99.48% (🟡 +0.02%)
/course/admin/mentor-tasks-review 335.28 KB 446.3 KB 89.26% (🟡 +0.01%)
/course/admin/mentors 390.92 KB 501.93 KB 100.39% (🟡 +0.01%)
/course/admin/stage-interviews 388.07 KB 499.09 KB 99.82% (🟡 +0.01%)
/course/admin/students 399.52 KB 510.54 KB 102.11% (🟡 +0.01%)
/course/admin/tasks 419.99 KB 531.01 KB 106.20% (🟡 +0.02%)
/course/admin/users 386.1 KB 497.12 KB 99.42% (🟡 +0.02%)
/course/interview/[type]/feedback 349.75 KB 460.77 KB 92.15% (🟡 +0.02%)
/course/mentor/auto-confirm 232.02 KB 343.04 KB 68.61% (🟡 +0.01%)
/course/mentor/confirm 298.83 KB 409.85 KB 81.97% (🟡 +0.01%)
/course/mentor/dashboard 406.69 KB 517.7 KB 103.54% (🟡 +0.01%)
/course/mentor/expel-student 302.79 KB 413.81 KB 82.76% (🟡 +0.02%)
/course/mentor/feedback 304.85 KB 415.87 KB 83.17% (🟡 +0.02%)
/course/mentor/interview-technical-screening 271.08 KB 382.1 KB 76.42% (🟡 +0.01%)
/course/mentor/interview-wait-list 343.94 KB 454.96 KB 90.99% (🟡 +0.02%)
/course/mentor/interviews 354.67 KB 465.69 KB 93.14% (🟡 +0.01%)
/course/mentor/students 254.92 KB 365.94 KB 73.19% (🟡 +0.01%)
/course/schedule 488.25 KB 599.27 KB 119.85% (🟡 +0.02%)
/course/score 343.4 KB 454.41 KB 90.88% (🟡 +0.02%)
/course/stats 291.62 KB 402.63 KB 80.53% (🟡 +0.01%)
/course/student/auto-test 396.79 KB 507.81 KB 101.56% (🟡 +0.02%)
/course/student/auto-test/task 396.7 KB 507.72 KB 101.54% (🟡 +0.02%)
/course/student/cross-check-review 489.37 KB 600.38 KB 120.08% (🟡 +0.01%)
/course/student/cross-check-submit 505.69 KB 616.71 KB 123.34% (🟡 +0.02%)
/course/student/dashboard 403.42 KB 514.44 KB 102.89% (🟡 +0.01%)
/course/student/interviews 308.86 KB 419.88 KB 83.97% (🟡 +0.02%)
/course/submit-scores 419.19 KB 530.21 KB 106.04% (🟡 +0.02%)
/course/team-distributions 387.71 KB 498.73 KB 99.75% (🟡 +0.01%)
/course/teams 434.17 KB 545.19 KB 109.04% (🟡 +0.01%)
/cv/[uuid] 249.32 KB 360.34 KB 72.07% (🟡 +0.01%)
/cv/edit 353.75 KB 464.77 KB 92.95% (🟡 +0.02%)
/gratitude 297.25 KB 408.26 KB 81.65% (🟡 +0.01%)
/heroes 403.58 KB 514.59 KB 102.92% (🟡 +0.01%)
/job 175.67 KB 286.69 KB 57.34% (🟡 +0.01%)
/profile 415 KB 526.01 KB 105.20% (🟡 +0.01%)
/profile/connection-confirmed 271.23 KB 382.25 KB 76.45% (🟡 +0.01%)
/profile/notifications 336.85 KB 447.87 KB 89.57% (🟡 +0.02%)
/registry/epamlearningjs 298.25 KB 409.26 KB 81.85% (🟡 +0.01%)
/registry/mentor 348.21 KB 459.23 KB 91.85% (🟡 +0.01%)
/registry/student 348.21 KB 459.22 KB 91.84% (🟡 +0.02%)
Details

Only 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 next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

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.

@Alphajax Alphajax merged commit 0ed6eba into master Jul 11, 2024
6 checks passed
@Alphajax Alphajax deleted the rs-app-2435 branch July 11, 2024 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants