Skip to content

Commit

Permalink
Cyberleague: [premieroctet#156] Add expertise_level_STR virtual field…
Browse files Browse the repository at this point in the history
… to expertiseLevel schema
  • Loading branch information
Bastien-Wappizy committed Sep 27, 2024
1 parent da41078 commit 25c89d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backend/web/server/plugins/cyberleague/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ declareEnumField({model: 'mission', field: 'estimation_duration_unit', enumValue
// ExpertiseSet declarations
declareVirtualField({model: 'expertiseSet', field: 'display_categories', requires: 'expertises,categories', instance: 'Array', multiple: true})

//ExpertiseLevel declarations
declareVirtualField({model: 'expertiseLevel', field: 'expertise_level_STR', requires: 'expertise.name', instance: 'String'})

//Score declarations
declareVirtualField({model: 'score', field: 'deviation', requires: 'answers.answer', instance: 'Number'})
declareVirtualField({model: 'score', field: 'question_count', require: 'answers', instance: 'Number'})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const mongoose = require('mongoose')
const {schemaOptions} = require('../../../utils/schemas')
const { DUMMY_REF } = require('../../../utils/database')

const Schema = mongoose.Schema

Expand All @@ -16,6 +17,9 @@ const ExpertiseLevelSchema = new Schema({
}, {schemaOptions})

/* eslint-disable prefer-arrow-callback */
ExpertiseLevelSchema.virtual('expertise_level_STR',DUMMY_REF).get(function () {
return `${this.expertise.name} : ${this.level}`
})
/* eslint-enable prefer-arrow-callback */

module.exports = ExpertiseLevelSchema

0 comments on commit 25c89d9

Please sign in to comment.