-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Ajout du continuum pour les diplomes 1<=>1 (#206)
feat: ajout d'une route bcn feat: ajout des stats manquantes (continuum) pour les anciens/nouveaux diplomes (1 pour 1)
- Loading branch information
Showing
67 changed files
with
4,158 additions
and
643 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
server/migrations/20230802092319-ajout_de_champs_dans_la_collection_BCN.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { omit, without } from "lodash-es"; | ||
import { arrayOf, date, string } from "../src/common/db/collections/jsonSchema/jsonSchemaTypes.js"; | ||
import * as MongoDB from "../src/common/db/mongodb.js"; | ||
|
||
const schema = { | ||
properties: { | ||
libelle_long: string(), | ||
date_ouverture: date(), | ||
date_premiere_session: string(), | ||
date_derniere_session: string(), | ||
ancien_diplome: arrayOf(string()), | ||
nouveau_diplome: arrayOf(string()), | ||
}, | ||
required: ["libelle_long"], | ||
}; | ||
|
||
export const up = async (db, client) => { | ||
MongoDB.setMongoDBClient(client); | ||
return MongoDB.mergeSchema("bcn", schema); | ||
}; | ||
|
||
export const down = async (db, client) => { | ||
const collectionInfos = await db.listCollections({ name: "bcn" }).toArray(); | ||
const validator = collectionInfos[0].options.validator; | ||
|
||
if (!validator) { | ||
return; | ||
} | ||
|
||
const oldSchema = validator.$jsonSchema; | ||
const newSchema = { | ||
...oldSchema, | ||
properties: omit(oldSchema.properties, Object.keys(schema.properties)), | ||
required: without(oldSchema.required, ...schema.required), | ||
}; | ||
|
||
return db.command({ | ||
collMod: "bcn", | ||
validationLevel: "strict", | ||
validationAction: "error", | ||
validator: { | ||
$jsonSchema: newSchema, | ||
}, | ||
}); | ||
}; |
54 changes: 54 additions & 0 deletions
54
...er/migrations/20230807122559-ajout_des_champs_pour_le_continuum_dans_la_collection_BCN.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { omit, without } from "lodash-es"; | ||
import { object, string, enumOf } from "../src/common/db/collections/jsonSchema/jsonSchemaTypes.js"; | ||
import * as MongoDB from "../src/common/db/mongodb.js"; | ||
|
||
const schema = { | ||
properties: { | ||
donnee_source: object( | ||
{ | ||
code_certification: string(), | ||
type: enumOf(["self", "ancienne", "nouvelle"]), | ||
}, | ||
{ required: ["code_certification", "type"] } | ||
), | ||
}, | ||
required: ["donnee_source"], | ||
}; | ||
|
||
export const up = async (db, client) => { | ||
MongoDB.setMongoDBClient(client); | ||
return Promise.all([ | ||
MongoDB.mergeSchema("certificationsStats", schema), | ||
MongoDB.mergeSchema("formationsStats", schema), | ||
MongoDB.mergeSchema("regionalesStats", schema), | ||
]); | ||
}; | ||
|
||
export const down = async (db, client) => { | ||
return Promise.all( | ||
["certificationsStats", "formationsStats", "regionalesStats"].map(async (collection) => { | ||
const collectionInfos = await db.listCollections({ name: collection }).toArray(); | ||
const validator = collectionInfos[0].options.validator; | ||
|
||
if (!validator) { | ||
return; | ||
} | ||
|
||
const oldSchema = validator.$jsonSchema; | ||
const newSchema = { | ||
...oldSchema, | ||
properties: omit(oldSchema.properties, Object.keys(schema.properties)), | ||
required: without(oldSchema.required || [], ...schema.required), | ||
}; | ||
|
||
return db.command({ | ||
collMod: collection, | ||
validationLevel: "strict", | ||
validationAction: "error", | ||
validator: { | ||
$jsonSchema: newSchema, | ||
}, | ||
}); | ||
}) | ||
); | ||
}; |
91 changes: 91 additions & 0 deletions
91
server/migrations/20230809131650-ajout_de_la_collection_bcn_mef.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { logger } from "../src/common/logger.js"; | ||
import { object, objectId, string, date } from "../src/common/db/collections/jsonSchema/jsonSchemaTypes.js"; | ||
|
||
const name = "bcn_mef"; | ||
|
||
function indexes() { | ||
return [[{ mef_stat_11: 1 }, { unique: true }], [{ mef: 1 }]]; | ||
} | ||
|
||
function schema() { | ||
return object( | ||
{ | ||
_id: objectId(), | ||
mef_stat_11: string(), | ||
mef: string(), | ||
dispositif_formation: string(), | ||
formation_diplome: string(), | ||
duree_dispositif: string(), | ||
annee_dispositif: string(), | ||
|
||
libelle_court: string(), | ||
libelle_long: string(), | ||
|
||
date_ouverture: date(), | ||
date_fermeture: date(), | ||
|
||
statut_mef: string(), | ||
nb_option_obligatoire: string(), | ||
nb_option_facultatif: string(), | ||
renforcement_langue: string(), | ||
duree_projet: string(), | ||
duree_stage: string(), | ||
horaire: string(), | ||
mef_inscription_scolarite: string(), | ||
mef_stat_9: string(), | ||
|
||
date_intervention: date(), | ||
libelle_edition: string(), | ||
commentaire: string(), | ||
_meta: object( | ||
{ | ||
created_on: date(), | ||
updated_on: date(), | ||
date_import: date(), | ||
}, | ||
{ required: ["date_import"] } | ||
), | ||
}, | ||
{ | ||
required: [ | ||
"mef", | ||
"dispositif_formation", | ||
"formation_diplome", | ||
"duree_dispositif", | ||
"annee_dispositif", | ||
"mef_stat_11", | ||
"libelle_court", | ||
"libelle_long", | ||
"_meta", | ||
], | ||
additionalProperties: true, | ||
} | ||
); | ||
} | ||
|
||
export const up = async (db, client) => { | ||
await db.createCollection(name); | ||
|
||
logger.debug(`Configuring indexes for collection ${name}...`); | ||
let dbCol = db.collection(name); | ||
|
||
await Promise.all( | ||
indexes().map(([index, options]) => { | ||
return dbCol.createIndex(index, options); | ||
}) | ||
); | ||
|
||
logger.debug(`Configuring validation for collection ${name}...`); | ||
await db.command({ | ||
collMod: name, | ||
validationLevel: "strict", | ||
validationAction: "error", | ||
validator: { | ||
$jsonSchema: schema(), | ||
}, | ||
}); | ||
}; | ||
|
||
export const down = async (db, client) => { | ||
// We do not remove the collection to avoid deleting data by error | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.