-
Notifications
You must be signed in to change notification settings - Fork 1
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
[Missions] Afficher un message d'avertissement quand une mission est déjà ouverte sur une unité #948
[Missions] Afficher un message d'avertissement quand une mission est déjà ouverte sur une unité #948
Conversation
.first { controlUnit -> controlUnit.first.id == entry.first }.first | ||
|
||
Pair(controlUnit, entry.second) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ca me paraît complexe de faire trois fonctions pour ce résultat mais je m'y connais pas assez pour trouver une autre manière de faire :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pareil, c'est la dernière étape (l. 42) qui est un peu dommage, à mon sens avant c'est indispensable (flatMap
+ groupBy
).
En gros le groupBy
doit être fait sur un id (ici), donc par la suite je dois re-composer l'objet (ici)
@ivangabriele t'aurais une idée ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Create a list of pairs `(LegacyControlUnit, MissionSourceEnum)`
val controlUnitAndMissionSourcePairs = openedMissions.flatMap { mission ->
mission.mission.controlUnits.map { controlUnit ->
logger.info("DBG ${controlUnit.id} - ${controlUnit.name}")
controlUnit to mission.mission.missionSource
}
}
// Group them by ControlUnit into a map `LegacyControlUnitEntity => List<MissionSourceEnum>`
val controlUnitToMissionSources = controlUnitAndMissionSourcePairs.groupBy({ it.first }, { it.second })
// Remove duplicates from each map entry values
.map { (controlUnit, missionSources) ->
ControlUnitToMissionSources(
controlUnit,
missionSources.distinct(),
)
}
logger.info("Found ${controlUnitToMissionSources.size} engaged control unit(s).")
return controlUnitToMissionSources
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'avais essayé cette méthode, ça ne fonctionnait pas, ça ne regroupait pas par controlUnit. Je n'ai pas compris pourquoi, alors que le groupby est censé utilisé equals
c84cc52
to
d9df20e
Compare
Related Pull Requests & Issues