Skip to content

Commit

Permalink
Ajoute une ConsoleAdministration permettant l'exécution d'opération…
Browse files Browse the repository at this point in the history
…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
CadiChris committed Oct 17, 2024
1 parent b4a67e3 commit 650d5da
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions anssi-nis2-api/src/consoleAdministration.ts
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}.`);
}
}

0 comments on commit 650d5da

Please sign in to comment.