Skip to content

Commit

Permalink
fixed tests + stats bacs pros
Browse files Browse the repository at this point in the history
  • Loading branch information
Numero7 committed Oct 23, 2024
1 parent 8bd00f0 commit 6081dbc
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

TRUNCATE TABLE ref_formation CASCADE;
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ public Collection<Integer> getLasFlCodes() {

public AdmissionStats buildStats() {

val bacsKeys = getBacs().stream().map(Bac::key).collect(Collectors.toSet());
val bacsKeys = new HashSet<>(getBacs().stream().map(Bac::key).toList());
bacsKeys.add(TOUS_BACS_CODE_MPS);
val groups = getGtaToMpsIdMapping();

StatistiquesAdmisParGroupe statsAdmisParGroupe
Expand Down Expand Up @@ -218,7 +219,6 @@ public void cleanupAfterUpdate() {
filActives.retainAll(formations().filieres.keySet());
//do not restrict to fil actives because we want to keep apprentissage
formations().cleanup();

Set<String> bacsActifs = new HashSet<>(stats.getBacsWithAtLeastNdAdmis(MIN_NB_ADMIS_FOR_BAC_ACTIF));
bacsActifs.add(TOUS_BACS_CODE_MPS);
this.stats.restrictToBacs(bacsActifs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class PsupStatistiques implements Serializable {

public static final String TOUS_GROUPES_CODE = "";

public static final String TOUS_BACS_CODE_LEGACY = "";
public static final String TOUS_BACS_CODE_MPS = "NC";

public static final int PRECISION_PERCENTILES = 40;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ public void set(Map<String, Map<String, int[]>> stringMapMap) {

public void minimize() {
parBac.values().forEach(StatistiquesAdmisParMatiere::minimize);
StatistiquesAdmisParMatiere s1 = parBac.get(PsupStatistiques.TOUS_BACS_CODE_LEGACY);
StatistiquesAdmisParMatiere s2 = parBac.get(PsupStatistiques.TOUS_BACS_CODE_MPS);
StatistiquesAdmisParMatiere s = s2 != null ? s2 : s1;
StatistiquesAdmisParMatiere s = parBac.get(PsupStatistiques.TOUS_BACS_CODE_MPS);
if(s == null) {
parBac.clear();
} else {
s.parMatiere().keySet().removeIf( m -> !m.equals(PsupStatistiques.MATIERE_MOYENNE_GENERALE_CODE) && !m.equals(PsupStatistiques.MATIERE_MOYENNE_BAC_CODE));
s.parMatiere().keySet().removeIf(
m -> !m.equals(PsupStatistiques.MATIERE_MOYENNE_GENERALE_CODE)
&& !m.equals(PsupStatistiques.MATIERE_MOYENNE_BAC_CODE)
);
Statistique ss = s.parMatiere().get(PsupStatistiques.MATIERE_MOYENNE_GENERALE_CODE);
if (ss == null) {
parBac.clear();
} else {
if (ss.nb() <= 3) {
parBac.keySet().removeIf( b -> !b.equals(PsupStatistiques.TOUS_BACS_CODE_LEGACY) && !b.equals(PsupStatistiques.TOUS_BACS_CODE_MPS));
parBac.keySet().removeIf( b -> !b.equals(PsupStatistiques.TOUS_BACS_CODE_MPS));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package fr.gouv.monprojetsup.data.etl.port
import fr.gouv.monprojetsup.data.Constants.gFlCodToMpsId
import fr.gouv.monprojetsup.data.Constants.gFrCodToMpsId
import fr.gouv.monprojetsup.data.TestData
import fr.gouv.monprojetsup.data.model.stats.PsupStatistiques
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
Expand Down Expand Up @@ -145,7 +146,8 @@ class FormationsMpsTests : DataPortTest() {

@Test
fun `tous les bacs de toutes les stats sont connus`() {
val keys = mpsDataPort.getBacs().map { b -> b.key }
val keys = HashSet(mpsDataPort.getBacs().map { b -> b.key })
keys.add(PsupStatistiques.TOUS_BACS_CODE_MPS)
val statsKeys = mpsDataPort.getStatsFormation().flatMap { it.value.nbAdmisParBac.keys }
assertThat(keys).containsAll(statsKeys)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

import static fr.gouv.monprojetsup.data.Constants.isFiliere;
import static fr.gouv.monprojetsup.data.Constants.isMetier;
import static fr.gouv.monprojetsup.data.model.stats.PsupStatistiques.TOUS_BACS_CODE_LEGACY;
import static fr.gouv.monprojetsup.data.model.stats.PsupStatistiques.TOUS_BACS_CODE_MPS;
import static fr.gouv.monprojetsup.suggestions.algo.Config.ADMISSIBILITY_10;
import static fr.gouv.monprojetsup.suggestions.algo.Config.ADMISSIBILITY_25;
Expand Down Expand Up @@ -101,8 +100,7 @@ public AffinityEvaluator(ProfileDTO pf, Config cfg, AlgoSuggestions algo, boolea
this.algo = algo;

String pfBac = pf.bac();
if(pfBac == null) pfBac = TOUS_BACS_CODE_MPS;
if(pfBac.equals(TOUS_BACS_CODE_LEGACY)) pfBac = TOUS_BACS_CODE_MPS;
if(pfBac == null || pfBac.isBlank()) pfBac = TOUS_BACS_CODE_MPS;
this.bac = pfBac;

try {
Expand Down

0 comments on commit 6081dbc

Please sign in to comment.