Skip to content

Commit

Permalink
[Act-Rep] Retirer des act-rep les contrôles faits par les unités AECP (
Browse files Browse the repository at this point in the history
…#3213)

## Linked issues

- Resolve #3194

----

- [ ] Tests E2E (Cypress)
  • Loading branch information
louptheron authored May 22, 2024
2 parents 2c472c9 + b22ed56 commit bba8d90
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ data class MissionAction(
val gearOnboard: List<GearControl> = listOf(),
val speciesOnboard: List<SpeciesControl> = listOf(),
val isFromPoseidon: Boolean,
/**
* This field is only used by the `GetVesselControls` use-case.
* /!\ Do not use it to get `controlUnits` as the field will be empty be default.
*/
var controlUnits: List<ControlUnit> = listOf(),
val isDeleted: Boolean,
val hasSomeGearsSeized: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ class GetActivityReports(
else -> throw IllegalArgumentException("Bad control type: ${control.actionType}")
}
}.filter { control ->
val controlMission = missions.firstOrNull { mission -> mission.id == control.missionId }
// All AECP reports are excluded from the response
// see: https://github.com/MTES-MCT/monitorfish/issues/3194
return@filter !control.controlUnits.any { controlUnit -> controlUnit.administration == "AECP" }
return@filter !(controlMission?.controlUnits?.any { controlUnit -> controlUnit.administration == "AECP" } ?: false)
}
logger.info("Found ${filteredControls.size} controls to report.")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,9 @@ class GetActivityReportsUTests {
actionDatetimeUtc = ZonedDateTime.now(),
portLocode = "AEFAT",
faoAreas = listOf("27.4.b", "27.4.c"),
actionType = MissionActionType.LAND_CONTROL,
actionType = MissionActionType.SEA_CONTROL,
gearOnboard = listOf(),
controlUnits = listOf(ControlUnit(123, "AECP", false, "Unit AECP", listOf())),
controlUnits = listOf(),
speciesOnboard = listOf(),
seizureAndDiversion = true,
isDeleted = false,
Expand Down Expand Up @@ -425,9 +425,10 @@ class GetActivityReportsUTests {
val missions = listOf(
Mission(
1,
missionTypes = listOf(MissionType.LAND),
missionTypes = listOf(MissionType.SEA),
missionSource = MissionSource.MONITORFISH,
isUnderJdp = false,
isUnderJdp = true,
controlUnits = listOf(ControlUnit(123, "AECP", false, "Unit AECP", listOf())),
isGeometryComputedFromControls = false,
startDateTimeUtc = ZonedDateTime.of(2020, 5, 5, 3, 4, 5, 3, ZoneOffset.UTC),
),
Expand Down

0 comments on commit bba8d90

Please sign in to comment.