Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge demo to prod #675

Merged
merged 6 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.gouv.monprojetsup.authentification.domain.entity

import fr.gouv.monprojetsup.eleve.domain.entity.Commune
import fr.gouv.monprojetsup.eleve.domain.entity.CommuneFavorite
import fr.gouv.monprojetsup.eleve.domain.entity.VoeuFormation
import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixAlternance
import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixDureeEtudesPrevue
Expand All @@ -19,7 +19,7 @@ sealed class ProfilEleve(open val id: String) : ProfilUtilisateur() {
val metiersFavoris: List<String>?,
val dureeEtudesPrevue: ChoixDureeEtudesPrevue?,
val alternance: ChoixAlternance?,
val communesFavorites: List<Commune>?,
val communesFavorites: List<CommuneFavorite>?,
val formationsFavorites: List<VoeuFormation>?,
val moyenneGenerale: Float?,
val corbeilleFormations: List<String>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package fr.gouv.monprojetsup.eleve.application.dto

import com.fasterxml.jackson.annotation.JsonProperty
import fr.gouv.monprojetsup.authentification.domain.entity.ProfilEleve
import fr.gouv.monprojetsup.eleve.domain.entity.Commune
import fr.gouv.monprojetsup.eleve.domain.entity.CommuneFavorite
import fr.gouv.monprojetsup.eleve.domain.entity.ModificationProfilEleve
import fr.gouv.monprojetsup.eleve.domain.entity.VoeuFormation
import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixAlternance
Expand Down Expand Up @@ -143,7 +143,7 @@ data class ModificationProfilDTO(
dureeEtudesPrevue = dureeEtudesPrevue,
alternance = alternance,
formationsFavorites = formationsFavorites?.map { it.toVoeuFormation() },
communesFavorites = communesFavorites?.map { it.toCommune() },
communesFavorites = communesFavorites?.map { it.toCommuneFavoris() },
specialites = specialites,
moyenneGenerale = moyenneGenerale,
centresInterets = centresInterets,
Expand All @@ -166,15 +166,15 @@ data class ModificationProfilDTO(
@JsonProperty("longitude")
val longitude: Double,
) {
constructor(commune: Commune) : this(
codeInsee = commune.codeInsee,
nom = commune.nom,
latitude = commune.latitude,
longitude = commune.longitude,
constructor(communeFavorite: CommuneFavorite) : this(
codeInsee = communeFavorite.codeInsee,
nom = communeFavorite.nom,
latitude = communeFavorite.latitude,
longitude = communeFavorite.longitude,
)

fun toCommune() =
Commune(
fun toCommuneFavoris() =
CommuneFavorite(
codeInsee = codeInsee,
nom = nom,
latitude = latitude,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package fr.gouv.monprojetsup.eleve.application.dto

import com.fasterxml.jackson.annotation.JsonProperty
import fr.gouv.monprojetsup.authentification.domain.entity.ProfilEleve
import fr.gouv.monprojetsup.eleve.domain.entity.Commune
import fr.gouv.monprojetsup.eleve.domain.entity.CommuneFavorite
import fr.gouv.monprojetsup.eleve.domain.entity.VoeuFormation
import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixAlternance
import fr.gouv.monprojetsup.referentiel.domain.entity.ChoixDureeEtudesPrevue
Expand Down Expand Up @@ -133,11 +133,11 @@ data class ProfilDTO(
@JsonProperty("longitude")
val longitude: Double,
) {
constructor(commune: Commune) : this(
codeInsee = commune.codeInsee,
nom = commune.nom,
latitude = commune.latitude,
longitude = commune.longitude,
constructor(communeFavorite: CommuneFavorite) : this(
codeInsee = communeFavorite.codeInsee,
nom = communeFavorite.nom,
latitude = communeFavorite.latitude,
longitude = communeFavorite.longitude,
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.gouv.monprojetsup.eleve.domain.entity

data class Commune(
data class CommuneFavorite(
val codeInsee: String,
val nom: String,
val latitude: Double,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ data class ModificationProfilEleve(
val metiersFavoris: List<String>? = null,
val dureeEtudesPrevue: ChoixDureeEtudesPrevue? = null,
val alternance: ChoixAlternance? = null,
val communesFavorites: List<Commune>? = null,
val communesFavorites: List<CommuneFavorite>? = null,
val formationsFavorites: List<VoeuFormation>? = null,
val moyenneGenerale: Float? = null,
val corbeilleFormations: List<String>? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.gouv.monprojetsup.eleve.infrastructure.entity

import fr.gouv.monprojetsup.eleve.domain.entity.Commune
import fr.gouv.monprojetsup.eleve.domain.entity.CommuneFavorite
import java.io.Serializable

data class CommuneEntity(
Expand All @@ -9,15 +9,15 @@ data class CommuneEntity(
val latitude: Double,
val longitude: Double,
) : Serializable {
constructor(commune: Commune) : this(
codeInsee = commune.codeInsee,
nom = commune.nom,
latitude = commune.latitude,
longitude = commune.longitude,
constructor(communeFavorite: CommuneFavorite) : this(
codeInsee = communeFavorite.codeInsee,
nom = communeFavorite.nom,
latitude = communeFavorite.latitude,
longitude = communeFavorite.longitude,
)

fun toCommune() =
Commune(
CommuneFavorite(
codeInsee = codeInsee,
nom = nom,
latitude = latitude,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package fr.gouv.monprojetsup.formation.application.dto
import fr.gouv.monprojetsup.commun.lien.application.dto.LienDTO
import fr.gouv.monprojetsup.eleve.application.dto.ModificationProfilDTO
import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecVoeuxAuxAlentours
import fr.gouv.monprojetsup.formation.domain.entity.CommuneCourte
import fr.gouv.monprojetsup.formation.domain.entity.CritereAnalyseCandidature
import fr.gouv.monprojetsup.formation.domain.entity.ExplicationGeographique
import fr.gouv.monprojetsup.formation.domain.entity.ExplicationsSuggestionDetaillees
Expand Down Expand Up @@ -48,6 +49,7 @@ data class FormationAvecExplicationsDTO(
val criteresAnalyseCandidature: List<CriteresAnalyseCandidatureDTO>,
val repartitionAdmisAnneePrecedente: RepartitionAdmisAnneePrecedenteDTO?,
val liens: List<LienDTO>,
val communes: List<CommuneCourteDTO>,
val voeux: List<VoeuAvecCommuneDTO>,
val communesFavoritesAvecLeursVoeux: List<CommuneAvecSesVoeuxDTO>,
val metiers: List<MetierDTO>,
Expand Down Expand Up @@ -76,12 +78,20 @@ data class FormationAvecExplicationsDTO(
communesFavoritesAvecLeursVoeux =
when (ficheFormation) {
is FicheFormation.FicheFormationPourProfil ->
ficheFormation.voeuxParCommunesFavorites.map {
ficheFormation.informationsSurLesVoeuxEtLeursCommunes.voeuxParCommunesFavorites.map {
CommuneAvecSesVoeuxDTO(it)
}

is FicheFormation.FicheFormationSansProfil -> emptyList()
},
communes =
when (ficheFormation) {
is FicheFormation.FicheFormationPourProfil ->
ficheFormation.informationsSurLesVoeuxEtLeursCommunes.communesTriees.map {
CommuneCourteDTO(it)
}
is FicheFormation.FicheFormationSansProfil -> emptyList()
},
metiers =
ficheFormation.metiers.map { metier ->
MetierDTO(metier)
Expand Down Expand Up @@ -276,7 +286,7 @@ data class FormationAvecExplicationsDTO(
constructor(
communeAvecVoeuxAuxAlentours: CommuneAvecVoeuxAuxAlentours,
) : this(
commune = ModificationProfilDTO.CommuneDTO(communeAvecVoeuxAuxAlentours.commune),
commune = ModificationProfilDTO.CommuneDTO(communeAvecVoeuxAuxAlentours.communeFavorite),
voeuxAvecDistance = communeAvecVoeuxAuxAlentours.distances.map { VoeuAvecDistanceDTO(it) },
)

Expand All @@ -299,11 +309,7 @@ data class FormationAvecExplicationsDTO(
constructor(voeu: Voeu) : this(
id = voeu.id,
nom = voeu.nom,
commune =
CommuneCourteDTO(
nom = voeu.commune.nom,
codeInsee = voeu.commune.codeInsee,
),
commune = CommuneCourteDTO(voeu.commune),
)
}

Expand All @@ -314,5 +320,10 @@ data class FormationAvecExplicationsDTO(
data class CommuneCourteDTO(
val nom: String,
val codeInsee: String,
)
) {
constructor(commune: CommuneCourte) : this(
nom = commune.nom,
codeInsee = commune.codeInsee,
)
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package fr.gouv.monprojetsup.formation.domain.entity

import fr.gouv.monprojetsup.eleve.domain.entity.Commune
import fr.gouv.monprojetsup.eleve.domain.entity.CommuneFavorite

data class CommuneAvecVoeuxAuxAlentours(
val commune: Commune,
val communeFavorite: CommuneFavorite,
val distances: List<VoeuAvecDistance>,
) {
data class VoeuAvecDistance(
Expand All @@ -13,7 +13,7 @@ data class CommuneAvecVoeuxAuxAlentours(
}

data class CommuneAvecIdsVoeuxAuxAlentours(
val commune: Commune,
val communeFavorite: CommuneFavorite,
val distances: List<VoeuAvecDistance>,
) {
data class VoeuAvecDistance(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package fr.gouv.monprojetsup.formation.domain.entity

data class CommuneCourte(
val nom: String,
val codeInsee: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ sealed class FicheFormation(
override val liens: List<Lien>,
override val criteresAnalyseCandidature: List<CritereAnalyseCandidature>,
override val statistiquesDesAdmis: StatistiquesDesAdmis?,
override val voeux: List<Voeu>,
override val apprentissage: Boolean,
val voeuxParCommunesFavorites: List<CommuneAvecVoeuxAuxAlentours>,
val informationsSurLesVoeuxEtLeursCommunes: InformationsSurLesVoeuxEtLeursCommunes,
val tauxAffinite: Int,
val metiersTriesParAffinites: List<Metier>,
val explications: ExplicationsSuggestionDetaillees?,
Expand All @@ -76,7 +75,7 @@ sealed class FicheFormation(
formationsAssociees = formationsAssociees,
liens = liens,
metiers = metiersTriesParAffinites,
voeux = voeux,
voeux = informationsSurLesVoeuxEtLeursCommunes.voeux,
criteresAnalyseCandidature = criteresAnalyseCandidature,
statistiquesDesAdmis = statistiquesDesAdmis,
apprentissage = apprentissage,
Expand All @@ -92,5 +91,11 @@ sealed class FicheFormation(
val baccalaureat: Baccalaureat,
val pourcentage: Int,
)

data class InformationsSurLesVoeuxEtLeursCommunes(
val voeux: List<Voeu>,
val communesTriees: List<CommuneCourte>,
val voeuxParCommunesFavorites: List<CommuneAvecVoeuxAuxAlentours>,
)
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package fr.gouv.monprojetsup.formation.domain.entity

import fr.gouv.monprojetsup.eleve.domain.entity.Commune

data class Voeu(
val id: String,
val nom: String,
val commune: Commune,
val commune: CommuneCourte,
val latitude: Double,
val longitude: Double,
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package fr.gouv.monprojetsup.formation.domain.port

import fr.gouv.monprojetsup.eleve.domain.entity.Commune
import fr.gouv.monprojetsup.eleve.domain.entity.CommuneFavorite
import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecIdsVoeuxAuxAlentours

interface CommunesAvecVoeuxAuxAlentoursRepository {
fun recupererVoeuxAutoursDeCommmune(communes: List<Commune>): List<CommuneAvecIdsVoeuxAuxAlentours>
fun recupererVoeuxAutoursDeCommmune(communeFavorites: List<CommuneFavorite>): List<CommuneAvecIdsVoeuxAuxAlentours>
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ interface VoeuRepository {
obsoletesInclus: Boolean,
): Map<String, List<Voeu>>

fun recupererLesVoeuxDUneFormation(idFormation: String): List<Voeu>
fun recupererLesVoeuxDUneFormation(
idFormation: String,
obsoletesInclus: Boolean,
): List<Voeu>

fun recupererIdsVoeuxInexistants(idsVoeux: List<String>): List<String>
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.gouv.monprojetsup.formation.infrastructure.entity

import fr.gouv.monprojetsup.eleve.domain.entity.Commune
import fr.gouv.monprojetsup.formation.domain.entity.CommuneCourte
import fr.gouv.monprojetsup.formation.domain.entity.Voeu

data class JoinFormationVoeuQuery(
Expand Down Expand Up @@ -29,11 +29,11 @@ data class JoinFormationVoeuQuery(
id = idVoeu,
nom = nomVoeu,
commune =
Commune(
CommuneCourte(
nom = nomCommune,
codeInsee = codeCommune,
latitude = latitude,
longitude = longitude,
),
latitude = latitude,
longitude = longitude,
)
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package fr.gouv.monprojetsup.formation.infrastructure.entity

import fr.gouv.monprojetsup.eleve.domain.entity.Commune
import fr.gouv.monprojetsup.formation.domain.entity.Voeu
import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.Id
Expand Down Expand Up @@ -30,17 +28,4 @@ class VoeuEntity {

@Column(name = "obsolete", nullable = false)
var obsolete: Boolean = false

fun toVoeu() =
Voeu(
id = id,
nom = nom,
commune =
Commune(
codeInsee = codeCommune,
nom = commune,
latitude = latitude,
longitude = longitude,
),
)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.gouv.monprojetsup.formation.infrastructure.repository

import fr.gouv.monprojetsup.eleve.domain.entity.Commune
import fr.gouv.monprojetsup.eleve.domain.entity.CommuneFavorite
import fr.gouv.monprojetsup.formation.domain.entity.CommuneAvecIdsVoeuxAuxAlentours
import fr.gouv.monprojetsup.formation.domain.port.CommunesAvecVoeuxAuxAlentoursRepository
import fr.gouv.monprojetsup.logging.MonProjetSupLogger
Expand All @@ -13,9 +13,9 @@ class CommunesAvecVoeuxAuxAlentoursBDDRepository(
private val logger: MonProjetSupLogger,
) : CommunesAvecVoeuxAuxAlentoursRepository {
@Transactional(readOnly = true)
override fun recupererVoeuxAutoursDeCommmune(communes: List<Commune>): List<CommuneAvecIdsVoeuxAuxAlentours> {
val entites = communesAvecVoeuxAuxAlentoursJPARepository.findAllByCodeInseeIn(communes.map { it.codeInsee })
return communes.map { commune ->
override fun recupererVoeuxAutoursDeCommmune(communeFavorites: List<CommuneFavorite>): List<CommuneAvecIdsVoeuxAuxAlentours> {
val entites = communesAvecVoeuxAuxAlentoursJPARepository.findAllByCodeInseeIn(communeFavorites.map { it.codeInsee })
return communeFavorites.map { commune ->
val distances =
entites.firstOrNull { communeAvecVoeuxAuxAlentours ->
commune.codeInsee == communeAvecVoeuxAuxAlentours.codeInsee
Expand All @@ -28,7 +28,7 @@ class CommunesAvecVoeuxAuxAlentoursBDDRepository(
)
}
CommuneAvecIdsVoeuxAuxAlentours(
commune = commune,
communeFavorite = commune,
distances =
distances?.map { distance ->
CommuneAvecIdsVoeuxAuxAlentours.VoeuAvecDistance(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,18 @@ class VoeuBDDRepository(
}

@Transactional(readOnly = true)
override fun recupererLesVoeuxDUneFormation(idFormation: String): List<Voeu> {
return findAllByIdFormationIn(listOf(idFormation)).map { it.toVoeu() }
override fun recupererLesVoeuxDUneFormation(
idFormation: String,
obsoletesInclus: Boolean,
): List<Voeu> {
val formations = listOf(idFormation)
return (
if (obsoletesInclus) {
findAllByIdFormationIn(formations)
} else {
findAllByIdFormationInNotObsolete(formations)
}
).map { it.toVoeu() }
}

@Transactional(readOnly = true)
Expand Down
Loading