diff --git a/backend/web/server/plugins/sosynpl/functions.js b/backend/web/server/plugins/sosynpl/functions.js index 493f46da19..c0d0239312 100644 --- a/backend/web/server/plugins/sosynpl/functions.js +++ b/backend/web/server/plugins/sosynpl/functions.js @@ -306,6 +306,7 @@ caster: { options: { ref: 'application' } },}) declareVirtualField({model: 'announce', field: 'expertises_count', instance: 'Number', requires: 'expertises'}) +declareVirtualField({model: 'announce', field: 'pinned_expertises_count', instance: 'Number', requires: 'pinned_expertises'}) declareVirtualField({model: 'announce', field: 'received_applications_count', instance: 'Number'}) declareEnumField({model: 'announce', field: 'experience', enumValues: EXPERIENCE}) declareVirtualField({model: 'announce', field: 'average_daily_rate', instance: 'Number', requires:'duration,duration_unit,budget'}) diff --git a/backend/web/server/plugins/sosynpl/schemas/AnnounceSchema.js b/backend/web/server/plugins/sosynpl/schemas/AnnounceSchema.js index fe8626451b..32ea01ffff 100644 --- a/backend/web/server/plugins/sosynpl/schemas/AnnounceSchema.js +++ b/backend/web/server/plugins/sosynpl/schemas/AnnounceSchema.js @@ -340,6 +340,13 @@ AnnounceSchema.virtual('expertises_count', { count: true, }) +AnnounceSchema.virtual('pinned_expertises_count', { + ref: 'expertise', + foreignField: '_id', + localField: 'pinned_expertises', + count: true, +}) + AnnounceSchema.virtual('average_daily_rate', DUMMY_REF).get(function() { if (!!this.duration && !!this.duration_unit && !!this.budget) { return this.budget/(this.duration*DURATION_UNIT_WORK_DAYS[this.duration_unit])