Skip to content

Commit

Permalink
Add is at port flag on vessel positions
Browse files Browse the repository at this point in the history
  • Loading branch information
louptheron committed Aug 14, 2024
1 parent 924fbc1 commit e051752
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ data class Position(
val positionType: PositionType,
val isManual: Boolean? = null,
val isFishing: Boolean? = null,
val isAtPort: Boolean? = null,

val latitude: Double,
val longitude: Double,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ data class PositionDataOutput(
val positionType: PositionType,
val isManual: Boolean? = null,
val isFishing: Boolean? = null,
val isAtPort: Boolean? = null,
) {
companion object {
fun fromPosition(position: Position): PositionDataOutput {
Expand All @@ -44,6 +45,7 @@ data class PositionDataOutput(
positionType = position.positionType,
isManual = position.isManual,
isFishing = position.isFishing,
isAtPort = position.isAtPort,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ data class PositionEntity(
val isManual: Boolean? = false,
@Column(name = "is_fishing")
val isFishing: Boolean? = false,
@Column(name = "is_at_port")
val isAtPort: Boolean? = null,

// Mandatory fields
@Enumerated(EnumType.STRING)
Expand Down Expand Up @@ -78,6 +80,7 @@ data class PositionEntity(
positionType = positionType,
isManual = isManual,
isFishing = isFishing,
isAtPort = isAtPort,
)

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ interface DBPositionRepository : CrudRepository<PositionEntity, Long> {
"p.course, " +
"p.position_type, " +
"p.is_manual, " +
"p.is_fishing " +
"p.is_fishing, " +
"p.is_at_port " +
"from positions p " +
"where p.internal_reference_number = :internalReferenceNumber " +
"and p.date_time >= :from " +
Expand Down Expand Up @@ -61,7 +62,8 @@ interface DBPositionRepository : CrudRepository<PositionEntity, Long> {
"p.course, " +
"p.position_type, " +
"p.is_manual, " +
"p.is_fishing " +
"p.is_fishing, " +
"p.is_at_port " +
"from positions p " +
"where p.external_reference_number = :externalReferenceNumber " +
"and p.date_time >= :from " +
Expand Down Expand Up @@ -94,7 +96,8 @@ interface DBPositionRepository : CrudRepository<PositionEntity, Long> {
"p.course, " +
"p.position_type, " +
"p.is_manual, " +
"p.is_fishing " +
"p.is_fishing, " +
"p.is_at_port " +
"from positions p " +
"where p.ircs = :ircs " +
"and p.date_time >= :from " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69278,3 +69278,6 @@ INSERT INTO POSITIONS (INTERNAL_REFERENCE_NUMBER, EXTERNAL_REFERENCE_NUMBER, MMS
('U_W0NTFINDME','ABC123456',null,'TALK2ME','MALOTRU','FR','FR','DE',null,57.348,-21.219,7.5,11,(now() AT TIME ZONE 'UTC')::TIMESTAMP - interval '20 days 9 hours','VMS'),
('U_W0NTFINDME','ABC123456',null,'TALK2ME','MALOTRU','FR','FR','DE',null,57.64,-21.117,8.6,17,(now() AT TIME ZONE 'UTC')::TIMESTAMP - interval '20 days 3 hours','VMS');

update positions
set is_at_port = true
where INTERNAL_REFERENCE_NUMBER = 'FAK000999999' and date_time < (now() AT TIME ZONE 'UTC')::TIMESTAMP - interval '22 hours';
2 changes: 2 additions & 0 deletions frontend/cypress/e2e/vessel_sidebar/control_buttons.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ context('Vessel sidebar controls buttons', () => {
// The table should be sorted in ascending datetime order
cy.get('.Table-SimpleTable').contains('GDH').click()
cy.get('[data-id="0"] > td').eq(2).contains('8.7 nds')
cy.get('[data-id="0"] > td').eq(1).find('[title="Position au port"]').should('exist')
cy.get('[data-id="0"] > td').eq(1).find('[title="Position manuelle (4h-report)"]').should('exist')
})

it('Vessel track dates Should be changed When walking in fishing trips', () => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/cypress/e2e/vessels/vessels_list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ context('Vessels list', () => {

return cy
.readFile(`cypress/downloads/${downloadedCSVFilename}`)
.should('contains', 'Quartier,CFR,C/S,Nom,GDH (UTC),MMSI,Latitude,Longitude,Cap,Vitesse')
.should('contains', 'Quartier,CFR,C/S,Nom,GDH (UTC),MMSI,Latitude,Longitude,Cap,Vitesse,Au port')
.should('contains', '"Duval","ABC000021309","","GENS SAISON PARMI"')
.should('contains', '"","48°43′41″N","002°44′53″W"')
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const DUMMY_VESSEL_TRACK = [
from: 'FR',
internalReferenceNumber: 'ABC000898396',
ircs: 'ZBRI',
isAtPort: false,
isFishing: true,
isManual: null,
latitude: 46.386,
Expand All @@ -27,6 +28,7 @@ export const DUMMY_VESSEL_TRACK = [
from: 'FR',
internalReferenceNumber: 'ABC000898396',
ircs: 'ZBRI',
isAtPort: false,
isFishing: true,
isManual: null,
latitude: 46.43,
Expand All @@ -46,6 +48,7 @@ export const DUMMY_VESSEL_TRACK = [
from: 'FR',
internalReferenceNumber: 'ABC000898396',
ircs: 'ZBRI',
isAtPort: false,
isFishing: null,
isManual: null,
latitude: 46.458,
Expand All @@ -65,6 +68,7 @@ export const DUMMY_VESSEL_TRACK = [
from: 'FR',
internalReferenceNumber: 'ABC000898396',
ircs: 'ZBRI',
isAtPort: false,
isFishing: null,
isManual: null,
latitude: 46.486,
Expand All @@ -84,6 +88,7 @@ export const DUMMY_VESSEL_TRACK = [
from: 'FR',
internalReferenceNumber: 'ABC000898396',
ircs: 'ZBRI',
isAtPort: false,
isFishing: null,
isManual: null,
latitude: 46.471,
Expand All @@ -103,6 +108,7 @@ export const DUMMY_VESSEL_TRACK = [
from: 'FR',
internalReferenceNumber: 'ABC000898396',
ircs: 'ZBRI',
isAtPort: false,
isFishing: null,
isManual: null,
latitude: 46.45,
Expand All @@ -125,6 +131,7 @@ export const VESSEL_TRACK_ALL_SAME_COORDINATES = [
from: 'FR',
internalReferenceNumber: 'FRA000915733',
ircs: 'FW7667',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 43.2942,
Expand All @@ -144,6 +151,7 @@ export const VESSEL_TRACK_ALL_SAME_COORDINATES = [
from: 'FR',
internalReferenceNumber: 'FRA000915733',
ircs: 'FW7667',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 43.2942,
Expand All @@ -163,6 +171,7 @@ export const VESSEL_TRACK_ALL_SAME_COORDINATES = [
from: 'FR',
internalReferenceNumber: 'FRA000915733',
ircs: 'FW7667',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 43.2942,
Expand All @@ -182,6 +191,7 @@ export const VESSEL_TRACK_ALL_SAME_COORDINATES = [
from: 'FR',
internalReferenceNumber: 'FRA000915733',
ircs: 'FW7667',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 43.2942,
Expand All @@ -201,6 +211,7 @@ export const VESSEL_TRACK_ALL_SAME_COORDINATES = [
from: 'FR',
internalReferenceNumber: 'FRA000915733',
ircs: 'FW7667',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 43.2942,
Expand All @@ -220,6 +231,7 @@ export const VESSEL_TRACK_ALL_SAME_COORDINATES = [
from: 'FR',
internalReferenceNumber: 'FRA000915733',
ircs: 'FW7667',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 43.2942,
Expand All @@ -239,6 +251,7 @@ export const VESSEL_TRACK_ALL_SAME_COORDINATES = [
from: 'FR',
internalReferenceNumber: 'FRA000915733',
ircs: 'FW7667',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 43.2942,
Expand All @@ -258,6 +271,7 @@ export const VESSEL_TRACK_ALL_SAME_COORDINATES = [
from: 'FR',
internalReferenceNumber: 'FRA000915733',
ircs: 'FW7667',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 43.2942,
Expand All @@ -277,6 +291,7 @@ export const VESSEL_TRACK_ALL_SAME_COORDINATES = [
from: 'FR',
internalReferenceNumber: 'FRA000915733',
ircs: 'FW7667',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 43.2942,
Expand All @@ -296,6 +311,7 @@ export const VESSEL_TRACK_ALL_SAME_COORDINATES = [
from: 'FR',
internalReferenceNumber: 'FRA000915733',
ircs: 'FW7667',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 43.2942,
Expand All @@ -315,6 +331,7 @@ export const VESSEL_TRACK_ALL_SAME_COORDINATES = [
from: 'FR',
internalReferenceNumber: 'FRA000915733',
ircs: 'FW7667',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 43.2942,
Expand All @@ -334,6 +351,7 @@ export const VESSEL_TRACK_ALL_SAME_COORDINATES = [
from: 'FR',
internalReferenceNumber: 'FRA000915733',
ircs: 'FW7667',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 43.2942,
Expand All @@ -356,6 +374,7 @@ export const VESSEL_TRACK_FEW_SAME_COORDINATES = [
from: 'FR',
internalReferenceNumber: 'FRA000915733',
ircs: 'FW7667',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 43.2948,
Expand All @@ -375,6 +394,7 @@ export const VESSEL_TRACK_FEW_SAME_COORDINATES = [
from: 'FR',
internalReferenceNumber: 'FRA000915733',
ircs: 'FW7667',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 43.2942,
Expand All @@ -394,6 +414,7 @@ export const VESSEL_TRACK_FEW_SAME_COORDINATES = [
from: 'FR',
internalReferenceNumber: 'FRA000915733',
ircs: 'FW7667',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 43.2942,
Expand All @@ -413,6 +434,7 @@ export const VESSEL_TRACK_FEW_SAME_COORDINATES = [
from: 'FR',
internalReferenceNumber: 'FRA000915733',
ircs: 'FW7667',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 43.2942,
Expand All @@ -432,6 +454,7 @@ export const VESSEL_TRACK_FEW_SAME_COORDINATES = [
from: 'FR',
internalReferenceNumber: 'FRA000915733',
ircs: 'FW7667',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 43.2953,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const DUMMY_VESSEL_TRACK_WITH_DUPLICATE_POSITIONS = [
from: 'FR',
internalReferenceNumber: 'FRA000703653',
ircs: 'FLIM',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 47.7936,
Expand All @@ -27,6 +28,7 @@ export const DUMMY_VESSEL_TRACK_WITH_DUPLICATE_POSITIONS = [
from: 'FR',
internalReferenceNumber: 'FRA000703653',
ircs: 'FLIM',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 47.7936,
Expand All @@ -46,6 +48,7 @@ export const DUMMY_VESSEL_TRACK_WITH_DUPLICATE_POSITIONS = [
from: 'FR',
internalReferenceNumber: 'FRA000703653',
ircs: 'FLIM',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 47.7941,
Expand All @@ -65,6 +68,7 @@ export const DUMMY_VESSEL_TRACK_WITH_DUPLICATE_POSITIONS = [
from: 'FR',
internalReferenceNumber: 'FRA000703653',
ircs: 'FLIM',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 47.7936,
Expand All @@ -84,6 +88,7 @@ export const DUMMY_VESSEL_TRACK_WITH_DUPLICATE_POSITIONS = [
from: 'FR',
internalReferenceNumber: 'FRA000703653',
ircs: 'FLIM',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 47.7936,
Expand All @@ -103,6 +108,7 @@ export const DUMMY_VESSEL_TRACK_WITH_DUPLICATE_POSITIONS = [
from: 'FR',
internalReferenceNumber: 'FRA000703653',
ircs: 'FLIM',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 47.7936,
Expand All @@ -122,6 +128,7 @@ export const DUMMY_VESSEL_TRACK_WITH_DUPLICATE_POSITIONS = [
from: 'FR',
internalReferenceNumber: 'FRA000703653',
ircs: 'FLIM',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 47.7936,
Expand All @@ -141,6 +148,7 @@ export const DUMMY_VESSEL_TRACK_WITH_DUPLICATE_POSITIONS = [
from: 'FR',
internalReferenceNumber: 'FRA000703653',
ircs: 'FLIM',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 47.7936,
Expand All @@ -160,6 +168,7 @@ export const DUMMY_VESSEL_TRACK_WITH_DUPLICATE_POSITIONS = [
from: 'FR',
internalReferenceNumber: 'FRA000703653',
ircs: 'FLIM',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 47.7936,
Expand All @@ -179,6 +188,7 @@ export const DUMMY_VESSEL_TRACK_WITH_DUPLICATE_POSITIONS = [
from: 'FR',
internalReferenceNumber: 'FRA000703653',
ircs: 'FLIM',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 47.7936,
Expand All @@ -198,6 +208,7 @@ export const DUMMY_VESSEL_TRACK_WITH_DUPLICATE_POSITIONS = [
from: 'FR',
internalReferenceNumber: 'FRA000703653',
ircs: 'FLIM',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 47.7481,
Expand All @@ -217,6 +228,7 @@ export const DUMMY_VESSEL_TRACK_WITH_DUPLICATE_POSITIONS = [
from: 'FR',
internalReferenceNumber: 'FRA000703653',
ircs: 'FLIM',
isAtPort: false,
isFishing: false,
isManual: false,
latitude: 47.7048,
Expand All @@ -236,6 +248,7 @@ export const DUMMY_VESSEL_TRACK_WITH_DUPLICATE_POSITIONS = [
from: 'FR',
internalReferenceNumber: 'FRA000703653',
ircs: 'FLIM',
isAtPort: false,
isFishing: true,
isManual: false,
latitude: 47.6723,
Expand All @@ -255,6 +268,7 @@ export const DUMMY_VESSEL_TRACK_WITH_DUPLICATE_POSITIONS = [
from: 'FR',
internalReferenceNumber: 'FRA000703653',
ircs: 'FLIM',
isAtPort: false,
isFishing: true,
isManual: false,
latitude: 47.6432,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ describe('vessel/track', () => {
from: 'FR',
internalReferenceNumber: 'ABC000898396',
ircs: 'ZBRI',
isAtPort: null,
isFishing: null,
isManual: null,
latitude: 46.386,
Expand Down
Loading

0 comments on commit e051752

Please sign in to comment.