Skip to content

Commit

Permalink
Refactor usage of sea control filter function
Browse files Browse the repository at this point in the history
  • Loading branch information
louptheron committed May 29, 2024
1 parent 58857df commit 217db88
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ enum class JointDeploymentPlan(private val species: List<FaoZonesAndSpecy>, priv

val isThirdCountryVessel = EU_THIRD_COUNTRIES.contains(control.flagState)

val isFirstJdpCurrentJdp = isFirstJdpFound(control)
val isFirstJdpCurrentJdp = isAttributedJdp(control)
if (!isFirstJdpCurrentJdp) {
return false
}
Expand Down Expand Up @@ -85,7 +85,7 @@ enum class JointDeploymentPlan(private val species: List<FaoZonesAndSpecy>, priv
): FAOArea? {
val jdpFaoAreas = this.getOperationalZones()

if (control.actionType == MissionActionType.SEA_CONTROL && !isFirstJdpFound(control)) {
if (control.actionType == MissionActionType.SEA_CONTROL && !isAttributedJdp(control)) {
return null
}

Expand All @@ -104,7 +104,7 @@ enum class JointDeploymentPlan(private val species: List<FaoZonesAndSpecy>, priv
* `JointDeploymentPlan.entries.firstOrNull` is the arbitrary rule to attach a control to only one JDP.
* see: https://github.com/MTES-MCT/monitorfish/issues/3157#issuecomment-2093036583
*/
private fun isFirstJdpFound(
fun isAttributedJdp(
control: MissionAction,
) = JointDeploymentPlan.entries
.firstOrNull { jdpEntry ->
Expand All @@ -114,7 +114,7 @@ enum class JointDeploymentPlan(private val species: List<FaoZonesAndSpecy>, priv
* `EASTERN_ATLANTIC_OPERATIONAL_ZONES without targeted species in catches.
*/
if (control.actionType == MissionActionType.SEA_CONTROL && jdpEntry == MEDITERRANEAN_AND_EASTERN_ATLANTIC) {
return@firstOrNull isMedJdp(control)
return@firstOrNull isMedJdpAttributed(control)
}

return@firstOrNull jdpEntry.getOperationalZones().any { jdpFaoArea ->
Expand All @@ -124,7 +124,7 @@ enum class JointDeploymentPlan(private val species: List<FaoZonesAndSpecy>, priv
}
} == this

private fun isMedJdp(
private fun isMedJdpAttributed(
control: MissionAction,
) = MEDITERRANEAN_AND_EASTERN_ATLANTIC.getOperationalZones().any { jdpFaoArea ->
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ class GetActivityReports(
}

if (control.faoAreas.isNotEmpty()) {
val foundFaoAreaIncludedInJdp = jdp.getFirstFaoAreaIncludedInJdp(control)

return@filter isUnderJdp && foundFaoAreaIncludedInJdp != null
return@filter isUnderJdp && jdp.isAttributedJdp(control)
}

// The mission must be under JDP
Expand Down

0 comments on commit 217db88

Please sign in to comment.