-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajoute une
ConsoleAdministration
permettant l'exécution d'opération…
…s d'admin On va commencer par la regénération de tous les événements Metabase pour y inclure l'éligibilité.
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as Knex from "knex"; | ||
import * as configurationKnex from "../knexfile"; | ||
import { AdaptateurJournalPostgres } from "./adaptateurs/adaptateurJournal.postgres"; | ||
import { AdaptateurEligibiliteCsv } from "./adaptateurs/adaptateurEligibilite.csv"; | ||
|
||
export class ConsoleAdministration { | ||
constructor( | ||
private readonly adaptateurJournal = new AdaptateurJournalPostgres(), | ||
private readonly adaptateurEligibilite = new AdaptateurEligibiliteCsv(), | ||
private readonly knexPersistance: Knex.Knex = Knex(configurationKnex), | ||
) {} | ||
|
||
public async genereTousEvenementsQuestionnaire() { | ||
const reponses = await this.knexPersistance("simulateur_reponse").select(); | ||
|
||
const succes = []; | ||
const erreurs = []; | ||
|
||
reponses.map(({ id, reponseJson }) => { | ||
try { | ||
const resultat = | ||
this.adaptateurEligibilite.evalueEligibilite(reponseJson); | ||
succes.push(resultat); | ||
} catch (e) { | ||
erreurs.push({ erreur: e, id: id }); | ||
} | ||
}); | ||
|
||
console.log(erreurs); | ||
|
||
console.log("-----------"); | ||
console.log(`RÉSUMÉ : ✅ ${succes.length}. 💥 ${erreurs.length}.`); | ||
} | ||
} |