Skip to content

Commit

Permalink
Enlève l’heuristique des organismes dans le déploiement
Browse files Browse the repository at this point in the history
  • Loading branch information
niladic committed Nov 6, 2024
1 parent 3e5efad commit 778dfda
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 26 deletions.
10 changes: 2 additions & 8 deletions app/controllers/ApiController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,7 @@ case class ApiController @Inject() (
"Accès non autorisé au dashboard de déploiement"
) { () =>
val userGroups = userGroupService.allOrThrow.filter(group =>
group.organisation
.orElse(Organisation.deductedFromName(group.name))
.exists(_.id === Organisation.franceServicesId)
group.organisation.exists(_.id === Organisation.franceServicesId)
)
val franceServiceInstances = organisationService.franceServiceInfos.instances
val doNotMatchTheseEmails =
Expand Down Expand Up @@ -439,11 +437,7 @@ case class ApiController @Inject() (
for {
group <- userGroups.filter(group =>
group.areaIds.contains[UUID](area.id)
&& organisationSet.exists(
group.organisation
.orElse(Organisation.deductedFromName(group.name))
.contains[Organisation]
)
&& organisationSet.exists(group.organisation.contains[Organisation])
)
user <- users if user.groupIds.contains[UUID](group.id)
} yield user
Expand Down
11 changes: 0 additions & 11 deletions app/models/Organisation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,4 @@ object Organisation {
subjects: Seq[Subject]
)

def deductedFromName(name: String): Option[Organisation] = {
val lowerCaseName = name.toLowerCase().stripSpecialChars
// Hack: `.reverse` the orgs so we can match first MSAP before MSA and
// Sous-Préf before Préf
all.reverse
.find { organisation =>
lowerCaseName.contains(organisation.shortName.toLowerCase().stripSpecialChars) ||
lowerCaseName.contains(organisation.name.toLowerCase().stripSpecialChars)
}
}

}
13 changes: 12 additions & 1 deletion app/serializers/UserAndGroupCsvSerializer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,22 @@ object UserAndGroupCsvSerializer {
}
}

def organisationFromNameHeuristic(name: String): Option[Organisation] = {
val lowerCaseName = name.toLowerCase().stripSpecialChars
// Hack: `.reverse` the orgs so we can match first MSAP before MSA and
// Sous-Préf before Préf
Organisation.all.reverse
.find { organisation =>
lowerCaseName.contains(organisation.shortName.toLowerCase().stripSpecialChars) ||
lowerCaseName.contains(organisation.name.toLowerCase().stripSpecialChars)
}
}

def matchOrganisationId: CSVMap = {
val optionOrganisation = csvMap
.get(GROUP_ORGANISATION.key)
.orElse(csvMap.get(GROUP_NAME.key))
.flatMap(Organisation.deductedFromName)
.flatMap(organisationFromNameHeuristic)
optionOrganisation match {
case Some(organisation) =>
csvMap + (GROUP_ORGANISATION.key -> organisation.id.id)
Expand Down
7 changes: 3 additions & 4 deletions app/views/allUsersByGroup.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,10 @@
</a>
}
@userGroup.areaIds.flatMap(Area.fromId).map(_.name).sorted.mkString(", ") /
<b>@userGroup.name</b> / @(userGroup.organisation, Organisation.deductedFromName(userGroup.name)) match {
case (Some(organisation), _) => {
<b>@userGroup.name</b> / @userGroup.organisation match {
case Some(organisation) => {
@organisation.shortName / }
case (_, Some(organisation)) => { @organisation.shortName / }
case _ => {}
case None => {}
} INSEE : @userGroup.inseeCode <br>
<span class="text--font-size-medium">@userGroup.description</span>
}{
Expand Down
4 changes: 2 additions & 2 deletions app/views/deploymentDashboard.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<div class="mdl-cell mdl-cell--12-col">
<a class="mdl-button mdl-button--raised" href="@routes.AreaController.franceServiceDeploymentDashboard">Tableau Déploiement France Services</a>
</div>
<h5 class="title--addline">Nombre d'agents instructeurs par organisation</h5>
<i>Les agents sont comptés double si ils sont dans plusieurs départements. Les organisations manquantes ne sont pas affichées. Certains agents ne sont pas détectés comme faisant partie d'une organisation (Vous devez corriger le groupe dans ce cas)</i>
<h5 class="title--addline">Nombre dagents instructeurs par organisme</h5>
<i>Les agents sont comptés double si ils sont dans plusieurs départements. Les organismes manquants ne sont pas affichés. Certains agents ne sont pas détectés comme faisant partie d'une organisation (Vous devez corriger le groupe dans ce cas)</i>
<div id="aplus-admin-deployment-table" class="mdl-cell mdl-cell--12-col"></div>
<div class="mdl-cell mdl-cell--12-col">
<a class="mdl-button mdl-button--raised" href="@routes.AreaController.deploymentDashboard?uniquement-fs=non">Afficher tous les organismes</a>
Expand Down

0 comments on commit 778dfda

Please sign in to comment.