Skip to content

Commit

Permalink
sosynpl project - [premieroctet#177] add pinned_expertise_count to an…
Browse files Browse the repository at this point in the history
…nounceSchema
  • Loading branch information
Batiste1998 committed Sep 11, 2024
1 parent 5cc3f65 commit 9a5f89f
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 @@ -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'})
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 @@ -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])
Expand Down

0 comments on commit 9a5f89f

Please sign in to comment.