From 4c8712435cd922764d7e9fbdd5dd79c62cb0f096 Mon Sep 17 00:00:00 2001 From: SeghirOumo Date: Tue, 6 Aug 2024 15:55:44 +0200 Subject: [PATCH] Sosynpl[#120]: removed freelance profile completion filter, added required attributes --- backend/web/server/plugins/sosynpl/functions.js | 4 ++-- backend/web/server/plugins/sosynpl/search.js | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/backend/web/server/plugins/sosynpl/functions.js b/backend/web/server/plugins/sosynpl/functions.js index 78904b5038..feaadecdb1 100644 --- a/backend/web/server/plugins/sosynpl/functions.js +++ b/backend/web/server/plugins/sosynpl/functions.js @@ -14,7 +14,7 @@ const { NATIONALITIES, PURCHASE_STATUS, LANGUAGE_LEVEL, REGIONS } = require("../ const {computeUserHardSkillsCategories, computeHSCategoryProgress } = require("./hard_skills"); const SoftSkill = require("../../models/SoftSkill"); const { computeAvailableGoldSoftSkills, computeAvailableSilverSoftSkills,computeAvailableBronzeSoftSkills } = require("./soft_skills"); -const { computeSuggestedFreelances, searchFreelances, countFreelances, searchAnnounces, countAnnounce } = require("./search"); +const { computeSuggestedFreelances, searchFreelances, countFreelances, searchAnnounces, countAnnounce, FREELANCE_SUGGESTION_REQUIRES } = require("./search"); const AnnounceSugggestion=require('../../models/AnnounceSuggestion') const cron = require('../../utils/cron') const moment = require('moment'); @@ -294,7 +294,7 @@ declareEnumField({model: 'softSkill', field: 'value', enumValues: SOFT_SKILLS}) /** Announce start */ declareVirtualField({model: 'announce', field: 'total_budget', instance: 'Number', requires: 'budget'}) -declareComputedField({model: 'announce', field: 'suggested_freelances', getterFn: computeSuggestedFreelances}) +declareComputedField({model: 'announce', field: 'suggested_freelances', requires: [...FREELANCE_SUGGESTION_REQUIRES].join(','), getterFn: computeSuggestedFreelances}) declareEnumField({model: 'announce', field: 'duration_unit', enumValues: DURATION_UNIT}) declareEnumField({model: 'announce', field: 'mobility', enumValues: ANNOUNCE_MOBILITY}) declareEnumField({model: 'announce', field: 'soft_skills', enumValues: SS_PILAR}) diff --git a/backend/web/server/plugins/sosynpl/search.js b/backend/web/server/plugins/sosynpl/search.js index d603b4dd8e..766f264fc9 100644 --- a/backend/web/server/plugins/sosynpl/search.js +++ b/backend/web/server/plugins/sosynpl/search.js @@ -9,6 +9,18 @@ const Announce = require('../../models/Announce') const { REGIONS_FULL } = require('../../../utils/consts') const { loadFromDb } = require('../../utils/database') +const FREELANCE_SUGGESTION_REQUIRES = [ + 'job', + 'sectors', + 'expertises', + 'softwares', + 'languages', + 'experience', + 'homework_days', + 'duration', + 'mobility' +] + const computeSuggestedFreelances = async (userId, params, data) => { const getRegionFromZipcode = (zipcode) => { const departmentCode = String(zipcode).substring(0, 2) @@ -53,8 +65,6 @@ const computeSuggestedFreelances = async (userId, params, data) => { .populate('experiences') .populate('trainings') - freelances = freelances.filter(freelance => freelance.freelance_profile_completion === 1) - freelances.forEach((freelance) => { let score = 0 let regionKey @@ -267,4 +277,5 @@ const countAnnounce = async (userId, params, data, fields) => { module.exports={ computeSuggestedFreelances, searchFreelances, countFreelances, searchAnnounces, countAnnounce, + FREELANCE_SUGGESTION_REQUIRES } \ No newline at end of file