Skip to content

Commit

Permalink
Merge branch 'main' into fix-codeql
Browse files Browse the repository at this point in the history
  • Loading branch information
lwih authored May 30, 2024
2 parents 48331ff + 9fc5244 commit de35172
Show file tree
Hide file tree
Showing 29 changed files with 750 additions and 269 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ data class MissionEntity(
val geom: MultiPolygon? = null,
val startDateTimeUtc: ZonedDateTime,
val endDateTimeUtc: ZonedDateTime? = null,
val isClosed: Boolean,
val isDeleted: Boolean,
val isGeometryComputedFromControls: Boolean,
val missionSource: MissionSourceEnum,
Expand Down Expand Up @@ -55,7 +54,6 @@ data class MissionEntity(
geom = envMission.mission.geom,
startDateTimeUtc = envMission.mission.startDateTimeUtc,
endDateTimeUtc = envMission.mission.endDateTimeUtc,
isClosed = envMission.mission.isClosed,
isDeleted = envMission.mission.isDeleted,
isGeometryComputedFromControls = envMission.mission.isGeometryComputedFromControls,
missionSource = envMission.mission.missionSource,
Expand All @@ -70,7 +68,6 @@ data class MissionEntity(
crew = navMission?.crew,
) {
this.status = this.calculateMissionStatus(
isClosed = envMission.mission.isClosed,
startDateTimeUtc = envMission.mission.startDateTimeUtc,
endDateTimeUtc = envMission.mission.endDateTimeUtc,
)
Expand Down Expand Up @@ -101,13 +98,12 @@ data class MissionEntity(
}

private fun calculateMissionStatus(
isClosed: Boolean,
startDateTimeUtc: ZonedDateTime,
endDateTimeUtc: ZonedDateTime? = null,
): MissionStatusEnum {
val compareDate = ZonedDateTime.now()

if (isClosed) {
if (endDateTimeUtc != null && ZonedDateTime.parse(endDateTimeUtc.toString()).isBefore(compareDate)) {
return MissionStatusEnum.ENDED
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ data class MissionEntity(
val startDateTimeUtc: ZonedDateTime,
val endDateTimeUtc: ZonedDateTime? = null,
var envActions: List<EnvActionEntity>? = listOf(),
val isClosed: Boolean,
val isDeleted: Boolean,
val isGeometryComputedFromControls: Boolean,
val missionSource: MissionSourceEnum,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ data class Mission(
val id: Int,
val missionTypes: List<MissionType>,
val openBy: String? = null,
val closedBy: String? = null,
val observationsCacem: String? = null,
val observationsCnsp: String? = null,
val facade: String? = null,
val geom: MultiPolygon? = null,
val startDateTimeUtc: ZonedDateTime,
val endDateTimeUtc: ZonedDateTime? = null,
val missionSource: MissionSource,
val isClosed: Boolean,
val hasMissionOrder: Boolean? = false,
val isUnderJdp: Boolean? = false,
val controlUnits: List<ControlUnit> = listOf(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ class FakeMissionData(
missionSource = MissionSourceEnum.RAPPORTNAV,
startDateTimeUtc = ZonedDateTime.parse("2024-01-09T09:00:00Z"),
endDateTimeUtc = ZonedDateTime.parse("2024-01-09T15:00:00Z"),
isClosed = false,
isDeleted = false,
isGeometryComputedFromControls = false,
hasMissionOrder = false,
Expand All @@ -130,7 +129,6 @@ class FakeMissionData(
missionSource = MissionSourceEnum.RAPPORTNAV,
startDateTimeUtc = ZonedDateTime.parse("2024-01-09T09:00:00Z"),
endDateTimeUtc = ZonedDateTime.parse("2024-01-09T15:00:00Z"),
isClosed = false,
isDeleted = false,
isGeometryComputedFromControls = false,
hasMissionOrder = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class GetEnvMissions(
observationsCacem = null,
startDateTimeUtc = ZonedDateTime.parse("2022-03-15T04:50:09Z"),
// endDateTimeUtc = ZonedDateTime.parse("2022-03-23T20:29:03Z"),
isClosed = true,
isDeleted = false,
missionSource = MissionSourceEnum.RAPPORTNAV,
hasMissionOrder = false,
Expand All @@ -38,7 +37,6 @@ class GetEnvMissions(
observationsCacem = null,
startDateTimeUtc = ZonedDateTime.parse("2022-02-15T04:50:09Z"),
endDateTimeUtc = ZonedDateTime.parse("2022-02-23T20:29:03Z"),
isClosed = true,
isDeleted = false,
missionSource = MissionSourceEnum.MONITORENV,
hasMissionOrder = false,
Expand All @@ -52,7 +50,6 @@ class GetEnvMissions(
observationsCacem = null,
startDateTimeUtc = ZonedDateTime.parse("2022-01-15T04:50:09Z"),
endDateTimeUtc = ZonedDateTime.parse("2022-01-23T20:29:03Z"),
isClosed = true,
isDeleted = false,
missionSource = MissionSourceEnum.MONITORFISH,
hasMissionOrder = false,
Expand All @@ -66,7 +63,6 @@ class GetEnvMissions(
observationsCacem = null,
startDateTimeUtc = ZonedDateTime.parse("2024-03-11T07:00:00Z"),
endDateTimeUtc = ZonedDateTime.parse("2024-03-22T18:00:00Z"),
isClosed = true,
isDeleted = false,
missionSource = MissionSourceEnum.MONITORFISH,
hasMissionOrder = false,
Expand All @@ -82,7 +78,6 @@ class GetEnvMissions(
observationsCacem = null,
startDateTimeUtc = ZonedDateTime.parse("2026-04-11T07:00:00Z"),
endDateTimeUtc = ZonedDateTime.parse("2026-03-22T18:00:00Z"),
isClosed = false,
isDeleted = false,
missionSource = MissionSourceEnum.RAPPORTNAV,
hasMissionOrder = false,
Expand All @@ -98,7 +93,6 @@ class GetEnvMissions(
observationsCacem = null,
startDateTimeUtc = ZonedDateTime.parse("2024-04-17T07:00:00Z"),
endDateTimeUtc = ZonedDateTime.parse("2026-03-22T18:00:00Z"),
isClosed = false,
isDeleted = false,
missionSource = MissionSourceEnum.MONITORENV,
hasMissionOrder = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import java.time.ZonedDateTime

data class Mission(
val id: Int,
val isClosed: Boolean,
val missionSource: MissionSourceEnum,
val startDateTimeUtc: ZonedDateTime,
val endDateTimeUtc: ZonedDateTime?,
Expand Down Expand Up @@ -43,7 +42,6 @@ data class Mission(

return Mission(
id = mission.id,
isClosed = mission.isClosed,
missionSource = mission.missionSource,
startDateTimeUtc = mission.startDateTimeUtc,
endDateTimeUtc = mission.endDateTimeUtc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ data class MissionDataOutput @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) co
val endDateTimeUtc: ZonedDateTime? = null,
val envActions: List<EnvActionEntity>? = null,
val missionSource: MissionSourceEnum,
val isClosed: Boolean,
val hasMissionOrder: Boolean,
val isUnderJdp: Boolean,
val isGeometryComputedFromControls: Boolean,
Expand All @@ -44,7 +43,6 @@ data class MissionDataOutput @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) co
endDateTimeUtc = endDateTimeUtc,
envActions = envActions,
missionSource = missionSource,
isClosed = isClosed,
hasMissionOrder = hasMissionOrder,
isUnderJdp = isUnderJdp,
isGeometryComputedFromControls = isGeometryComputedFromControls,
Expand All @@ -70,7 +68,6 @@ data class MissionDataOutput @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) co
endDateTimeUtc = mission.endDateTimeUtc,
envActions = mission.envActions,
missionSource = mission.missionSource,
isClosed = mission.isClosed,
hasMissionOrder = mission.hasMissionOrder,
isUnderJdp = mission.isUnderJdp,
isGeometryComputedFromControls = mission.isGeometryComputedFromControls,
Expand Down
1 change: 0 additions & 1 deletion backend/src/main/resources/graphql/mission.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ input MissionInput {

type Mission {
id: ID!
isClosed: Boolean!
missionSource: String!
startDateTimeUtc: String!
endDateTimeUtc: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ class MissionEntityTests {
@Nested
inner class CalculateMissionStatus {
@Test
fun `should return ENDED when isClosed is true`() {
fun `should return ENDED when the endDate is prior than now`() {
val mission = MissionEntity(
envMission = ExtendedEnvMissionEntity.fromEnvMission(EnvMissionMock.create(isClosed = true)),
envMission = ExtendedEnvMissionEntity.fromEnvMission(
EnvMissionMock.create(
startDateTimeUtc = ZonedDateTime.now().minusDays(14),
endDateTimeUtc = ZonedDateTime.now().minusDays(2)
)
),
fishMissionActions = listOf(FishActionControlMock.create()).map {
ExtendedFishActionEntity.fromMissionAction(
it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ object EnvMissionMock {
geom: MultiPolygon? = null,
startDateTimeUtc: ZonedDateTime = ZonedDateTime.of(LocalDateTime.of(2022, 1, 2, 12, 0), ZoneOffset.UTC),
endDateTimeUtc: ZonedDateTime? = null,
isClosed: Boolean = false,
isDeleted: Boolean = false,
isGeometryComputedFromControls: Boolean = false,
missionSource: MissionSourceEnum = MissionSourceEnum.MONITORENV,
Expand All @@ -43,7 +42,6 @@ object EnvMissionMock {
geom = geom,
startDateTimeUtc = startDateTimeUtc,
endDateTimeUtc = endDateTimeUtc,
isClosed = isClosed,
isDeleted = isDeleted,
isGeometryComputedFromControls = isGeometryComputedFromControls,
missionSource = missionSource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ object FishMissionMock {
geom: MultiPolygon? = null,
startDateTimeUtc: ZonedDateTime = ZonedDateTime.of(LocalDateTime.of(2022, 1, 2, 12, 0), ZoneOffset.UTC),
endDateTimeUtc: ZonedDateTime? = null,
isClosed: Boolean = false,
missionSource: MissionSource = MissionSource.MONITORENV,
hasMissionOrder: Boolean = false,
isUnderJdp: Boolean = false,
Expand All @@ -36,7 +35,6 @@ object FishMissionMock {
geom = geom,
startDateTimeUtc = startDateTimeUtc,
endDateTimeUtc = endDateTimeUtc,
isClosed = isClosed,
missionSource = missionSource,
hasMissionOrder = hasMissionOrder,
isUnderJdp = isUnderJdp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ object MissionEntityMock {
geom: MultiPolygon? = null,
startDateTimeUtc: ZonedDateTime = ZonedDateTime.of(LocalDateTime.of(2022, 1, 2, 12, 0), ZoneOffset.UTC),
endDateTimeUtc: ZonedDateTime? = null,
isClosed: Boolean = false,
isDeleted: Boolean = false,
isGeometryComputedFromControls: Boolean = false,
missionSource: MissionSourceEnum = MissionSourceEnum.MONITORENV,
Expand All @@ -43,7 +42,6 @@ object MissionEntityMock {
geom = geom,
startDateTimeUtc = startDateTimeUtc,
endDateTimeUtc = endDateTimeUtc,
isClosed = isClosed,
isDeleted = isDeleted,
isGeometryComputedFromControls = isGeometryComputedFromControls,
missionSource = missionSource,
Expand Down
40 changes: 39 additions & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"type-fest": "^4.16.0",
"unleash-proxy-client": "^3.3.1",
"uuid": "^9.0.1",
"web-vitals": "^2.1.4"
"web-vitals": "^2.1.4",
"yup": "^1.4.0"
},
"devDependencies": {
"@import-meta-env/cli": "^0.6.8",
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/apollo-client.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { ApolloClient, ApolloLink, createHttpLink, InMemoryCache } from '@apollo/client'
import { loadDevMessages, loadErrorMessages } from '@apollo/client/dev'
import AuthToken from './auth/token'
import { setContext } from '@apollo/client/link/context'
import { RetryLink } from '@apollo/client/link/retry'
import { ErrorResponse, onError } from '@apollo/client/link/error'
import { removeTypenameFromVariables } from '@apollo/client/link/remove-typename'
import { RetryLink } from '@apollo/client/link/retry'
import AuthToken from './auth/token'

const removeTypenameLink = removeTypenameFromVariables()

const authToken = new AuthToken()

Expand Down Expand Up @@ -63,7 +66,7 @@ export const apolloCache = new InMemoryCache({})

const client = new ApolloClient({
cache: apolloCache,
link: ApolloLink.from([authLink, errorLink, logTimeLink, retryLink, httpLink]),
link: ApolloLink.from([removeTypenameLink, authLink, errorLink, logTimeLink, retryLink, httpLink]),
credentials: 'include',
connectToDevTools: true
})
Expand Down
Loading

0 comments on commit de35172

Please sign in to comment.