Skip to content

Commit

Permalink
sosynpl project - [premieroctet#175] add expertise_count to announceS…
Browse files Browse the repository at this point in the history
…chema
  • Loading branch information
Batiste1998 committed Sep 11, 2024
1 parent 376c290 commit 476dc21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/web/server/plugins/sosynpl/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ caster: {
instance: 'ObjectID',
options: { ref: 'application' }
},})
declareVirtualField({model: 'announce', field: 'expertises_count', instance: 'Number', requires: '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'})
Expand Down
7 changes: 7 additions & 0 deletions backend/web/server/plugins/sosynpl/schemas/AnnounceSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,13 @@ AnnounceSchema.virtual('received_applications_count', {
count: true,
})

AnnounceSchema.virtual('expertises_count', {
ref: 'expertise',
foreignField: '_id',
localField: '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])
Expand Down

0 comments on commit 476dc21

Please sign in to comment.