Skip to content
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

Back & Front - remove isStart for status action #86

Merged
merged 3 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -68,7 +68,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -81,6 +81,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
32 changes: 16 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: "[Release] Mirror push to gitlab"

on:
push:
branches: [ "main" ]
# push:
# branches: [ "main" ]
release:
types: [ published ]
workflow_dispatch:
Expand All @@ -19,20 +19,20 @@ jobs:
with:
fetch-depth: 0

# - name: Get frontend version
# uses: avides/[email protected]
# id: frontend_version
# with:
# token: ${{ secrets.GITHUB_TOKEN }}
# file-to-check: frontend/package.json
# only-return-version: true
#
# - name: Upload Frontend sourcemaps
# uses: ./.github/actions/upload-sourcemaps
# with:
# SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
# VERSION: ${{ steps.frontend_version.outputs.version }}
#test
- name: Get frontend version
uses: avides/[email protected]
id: frontend_version
with:
token: ${{ secrets.GITHUB_TOKEN }}
file-to-check: frontend/package.json
only-return-version: true

- name: Upload Frontend sourcemaps
uses: ./.github/actions/upload-sourcemaps
with:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
VERSION: ${{ steps.frontend_version.outputs.version }}

- uses: yesolutions/mirror-action@master
with:
REMOTE: https://gitlab-sml.din.developpement-durable.gouv.fr/rapportnav-v2/rapportnav_v2.git
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ data class ActionStatusEntity(
val startDateTimeUtc: ZonedDateTime,
val status: ActionStatusType,
val reason: ActionStatusReason? = null,
val isStart: Boolean,
val observations: String? = null,
) {
fun toNavAction(): NavActionEntity {
Expand All @@ -33,9 +32,7 @@ data class ActionStatusEntity(
startDateTimeUtc = startDateTimeUtc,
status = status,
reason = reason,
isStart = isStart,
observations = observations,

)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,8 @@ class GetStatusForAction(
val lastActionStatus = actions
.filter { it.startDateTimeUtc <= actionStartDateTimeUtc }
.maxByOrNull { it.startDateTimeUtc }
val lastStartedActionStatus = actions
.filter { it.isStart && it.startDateTimeUtc <= actionStartDateTimeUtc }
.maxByOrNull { it.startDateTimeUtc }


// case where there are 2 statuses at the same timestamp, one starting, one ending:
if (lastActionStatus != null && lastStartedActionStatus != null && lastStartedActionStatus.startDateTimeUtc == lastActionStatus.startDateTimeUtc) {
return lastStartedActionStatus.status
}
// return unknown if no action or if last action is a status of type finishing and no other starting action at that timestamp
else if (lastActionStatus == null || (!lastActionStatus.isStart && lastStartedActionStatus?.startDateTimeUtc != lastActionStatus.startDateTimeUtc)) {
return ActionStatusType.UNKNOWN
}
// return status of last status, it implies it is a starting status
else {
return lastActionStatus.status
}
return lastActionStatus?.status ?: ActionStatusType.UNKNOWN
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ data class ActionStatusInput(
val startDateTimeUtc: String?,
val status: ActionStatusType,
val reason: ActionStatusReason?,
val isStart: Boolean,
val observations: String?
) {
fun toActionStatus(): ActionStatusEntity {
Expand All @@ -26,7 +25,6 @@ data class ActionStatusInput(
} ?: ZonedDateTime.now(ZoneId.of("UTC")),
status = status,
reason = reason,
isStart = isStart,
observations = observations
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ data class Action(
fun sortForTimeline(allActions: List<Action>?): List<Action>? {
return allActions?.sortedWith(compareByDescending<Action> { it.startDateTimeUtc }
.thenBy { it.data is NavActionStatus }
.thenBy { (it.data as? NavActionStatus)?.isStart == false }
.thenBy { (it.data as? NavActionStatus)?.isStart == true }
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ data class NavActionStatus(
val startDateTimeUtc: ZonedDateTime,
val status: ActionStatusType,
val reason: ActionStatusReason? = null,
val isStart: Boolean,
val observations: String? = null
) : ActionData()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ class ActionStatusModel(
@Column(name = "reason", nullable = true)
var reason: String?,

@Column(name = "is_start", nullable = false)
var isStart: Boolean,

@Column(name = "observations", nullable = true)
var observations: String?,

Expand All @@ -44,7 +41,6 @@ class ActionStatusModel(
startDateTimeUtc = startDateTimeUtc,
status = mapStringToActionStatusType(status),
reason = mapStringToActionStatusReason(reason),
isStart = isStart,
observations = observations,
)
}
Expand All @@ -56,7 +52,6 @@ class ActionStatusModel(
startDateTimeUtc = statusAction.startDateTimeUtc,
status = statusAction.status.toString(),
reason = statusAction.reason.toStringOrNull(),
isStart = statusAction.isStart,
observations = statusAction.observations,
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
DO
$$
BEGIN

-- Remove the isStart column from the mission_action_status table
ALTER TABLE mission_action_status
DROP COLUMN is_start;

END
$$;
2 changes: 0 additions & 2 deletions backend/src/main/resources/graphql/action.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ input ActionStatusInput {
startDateTimeUtc: String
status: ActionStatusType!
reason: ActionStatusReason
isStart: Boolean!
observations: String
}

Expand Down Expand Up @@ -63,7 +62,6 @@ type NavActionStatus {
startDateTimeUtc: String!
status: ActionStatusType!
reason: ActionStatusReason
isStart: Boolean!
observations: String
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,47 +43,20 @@ class GetStatusForActionTests {
@Autowired
private lateinit var getStatusForAction: GetStatusForAction

// @Test
// fun `execute Should return Unknown when action is null for a mission`() {
// given(this.statusActionsRepository.findAllByMissionId(missionId)).willReturn(null);
// val statusForAction = getStatusForAction.execute(missionId=missionId, actionStartDateTimeUtc=null);
// assertThat(statusForAction).isEqualTo(ActionStatusType.UNKNOWN);
// }
@Test
fun `execute Should return Unknown when action is empty list for a mission`() {
given(this.statusActionsRepository.findAllByMissionId(missionId = 1)).willReturn(listOf<ActionStatusModel>());
val statusForAction = getStatusForAction.execute(missionId = missionId, actionStartDateTimeUtc = null);
assertThat(statusForAction).isEqualTo(ActionStatusType.UNKNOWN);
}

@Test
fun `execute Should return Unknown if only finishing actions`() {
val startDatetime = ZonedDateTime.of(2023, 6, 19, 10, 0, 0, 0, ZoneId.of("Europe/Berlin"))
val finishingAction = ActionStatusEntity(
id = UUID.randomUUID(),
missionId = missionId,
startDateTimeUtc = startDatetime,
isStart = false,
status = ActionStatusType.UNAVAILABLE,
)
val actions = listOf(finishingAction)
given(this.statusActionsRepository.findAllByMissionId(missionId = 1)).willReturn(actions.map {
ActionStatusModel.fromActionStatusEntity(
it
)
});
val statusForAction = getStatusForAction.execute(missionId = missionId, actionStartDateTimeUtc = startDatetime);
assertThat(statusForAction).isEqualTo(ActionStatusType.UNKNOWN);
}

@Test
fun `execute Should return the last action status if the last action is a starting status`() {
val startDatetime = ZonedDateTime.of(2023, 6, 19, 10, 0, 0, 0, ZoneId.of("Europe/Berlin"))
val startingAction = ActionStatusEntity(
id = UUID.randomUUID(),
missionId = missionId,
startDateTimeUtc = startDatetime,
isStart = true,
status = ActionStatusType.UNAVAILABLE,
)
val actions = listOf(startingAction)
Expand All @@ -95,31 +68,4 @@ class GetStatusForActionTests {
val statusForAction = getStatusForAction.execute(missionId = missionId, actionStartDateTimeUtc = startDatetime);
assertThat(statusForAction).isEqualTo(ActionStatusType.UNAVAILABLE);
}

@Test
fun `execute Should return the last started action status if last action is ending but at the same timestamp as a starting status action`() {
val startDatetime = ZonedDateTime.of(2023, 6, 19, 10, 0, 0, 0, ZoneId.of("Europe/Berlin"))
val startingAction = ActionStatusEntity(
id = UUID.randomUUID(),
missionId = missionId,
startDateTimeUtc = startDatetime,
isStart = true,
status = ActionStatusType.UNAVAILABLE,
)
val finishingAction = ActionStatusEntity(
id = UUID.randomUUID(),
missionId = missionId,
startDateTimeUtc = startDatetime,
isStart = false,
status = ActionStatusType.DOCKED,
)
val actions = listOf(finishingAction, startingAction)
given(this.statusActionsRepository.findAllByMissionId(missionId = 1)).willReturn(actions.map {
ActionStatusModel.fromActionStatusEntity(
it
)
});
val statusForAction = getStatusForAction.execute(missionId = missionId, actionStartDateTimeUtc = startDatetime);
assertThat(statusForAction).isEqualTo(startingAction.status);
}
}
Loading
Loading