Skip to content

Commit

Permalink
Sosynpl: [premieroctet#90] Return hard skill categories children skills
Browse files Browse the repository at this point in the history
  • Loading branch information
sebaauvray committed Aug 1, 2024
1 parent 085cfcc commit 79534c4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions backend/web/server/plugins/sosynpl/hard_skills.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ const User = require('../../models/User')
const computeUserHardSkillsCategories = async (userId, params, data) => {
const categories=await HardSkillCategory.find({parent: null})
.populate(['skills', {path: 'children', populate: ['children', 'skills']}])
const skills=[]
// Get user main job's skills
const user=await User.findById(userId).populate({path: 'main_job', populate: {path: 'job_file', populate: 'hard_skills'}})
const skills=user.main_job.job_file.hard_skills
console.log('user skills are', skills)
// Keep only categories containing hard skills linked to the main job's jobfile
const keep_category= (category) => {
// Has skill: keep only if contains user skills
Expand All @@ -21,7 +24,7 @@ const computeUserHardSkillsCategories = async (userId, params, data) => {
return new HardSkillCategory({
...category.toObject(),
children: category.children.filter(child => keep_category(child)).map(child => map_category(child)),
skills: category.skills.filter(s => skills.some(us => idEqual(us, s._id)))
skills: category.skills.filter(s => skills.some(us => idEqual(us._id, s._id)))
})
}
const filtered_categories=categories
Expand Down

0 comments on commit 79534c4

Please sign in to comment.