From 79534c4b45797c554dc690dbbe6631294dc34076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Auvray?= Date: Thu, 1 Aug 2024 15:22:18 +0200 Subject: [PATCH] Sosynpl: [#90] Return hard skill categories children skills --- backend/web/server/plugins/sosynpl/hard_skills.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/web/server/plugins/sosynpl/hard_skills.js b/backend/web/server/plugins/sosynpl/hard_skills.js index 673454647c..99d7f03e1f 100644 --- a/backend/web/server/plugins/sosynpl/hard_skills.js +++ b/backend/web/server/plugins/sosynpl/hard_skills.js @@ -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 @@ -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