diff --git a/backend/bloom/domain/excursion.py b/backend/bloom/domain/excursion.py index 51aebcbd..5d28d91e 100644 --- a/backend/bloom/domain/excursion.py +++ b/backend/bloom/domain/excursion.py @@ -29,6 +29,6 @@ class Excursion(BaseModel): total_time_fishing_in_amp: Union[timedelta, None] = None total_time_fishing_in_territorial_waters: Union[timedelta, None] = None total_time_fishing_in_costal_waters: Union[timedelta, None] = None - total_time_extincting_amp: Union[timedelta, None] = None + total_time_default_ais: Union[timedelta, None] = None created_at: Union[datetime, None] = None updated_at: Union[datetime, None] = None diff --git a/backend/bloom/infra/database/sql_model.py b/backend/bloom/infra/database/sql_model.py index 91652f13..b1a0d2dd 100644 --- a/backend/bloom/infra/database/sql_model.py +++ b/backend/bloom/infra/database/sql_model.py @@ -192,7 +192,7 @@ class Excursion(Base): total_time_fishing_in_amp = Column("total_time_fishing_in_amp", Interval) total_time_fishing_in_territorial_waters = Column("total_time_fishing_in_territorial_waters", Interval) total_time_fishing_in_costal_waters = Column("total_time_fishing_in_costal_waters", Interval) - total_time_extincting_amp = Column("total_time_extincting_amp", Interval) + total_time_default_ais = Column("total_time_default_ais", Interval) created_at = Column("created_at", DateTime(timezone=True), server_default=func.now()) updated_at = Column("updated_at", DateTime(timezone=True), onupdate=func.now()) diff --git a/backend/bloom/infra/repositories/repository_excursion.py b/backend/bloom/infra/repositories/repository_excursion.py index 5f869585..10bf9ab9 100644 --- a/backend/bloom/infra/repositories/repository_excursion.py +++ b/backend/bloom/infra/repositories/repository_excursion.py @@ -135,7 +135,7 @@ def map_to_sql(excursion: Excursion) -> sql_model.Excursion: total_time_fishing_in_amp=excursion.total_time_fishing_in_amp, total_time_fishing_in_territorial_waters=excursion.total_time_fishing_in_territorial_waters, total_time_fishing_in_costal_waters=excursion.total_time_fishing_in_costal_waters, - total_time_extincting_amp=excursion.total_time_extincting_amp, + total_time_default_ais=excursion.total_time_default_ais, created_at=excursion.created_at, updated_at=excursion.updated_at ) @@ -160,7 +160,7 @@ def map_to_domain(excursion: sql_model.Excursion) -> Excursion: total_time_fishing_in_amp=excursion.total_time_fishing_in_amp, total_time_fishing_in_territorial_waters=excursion.total_time_fishing_in_territorial_waters, total_time_fishing_in_costal_waters=excursion.total_time_fishing_in_costal_waters, - total_time_extincting_amp=excursion.total_time_extincting_amp, + total_time_default_ais=excursion.total_time_default_ais, created_at=excursion.created_at, updated_at=excursion.updated_at ) @@ -186,7 +186,7 @@ def map_to_orm(excursion: Excursion) -> sql_model.Excursion: total_time_fishing_in_amp=excursion.total_time_fishing_in_amp, total_time_fishing_in_territorial_waters=excursion.total_time_fishing_in_territorial_waters, total_time_fishing_in_costal_waters=excursion.total_time_fishing_in_costal_waters, - total_time_extincting_amp=excursion.total_time_extincting_amp, + total_time_default_ais=excursion.total_time_default_ais, created_at=excursion.created_at, updated_at=excursion.updated_at ) diff --git a/backend/bloom/tasks/create_update_excursions_segments.py b/backend/bloom/tasks/create_update_excursions_segments.py index 3629fbd4..4c4c768d 100644 --- a/backend/bloom/tasks/create_update_excursions_segments.py +++ b/backend/bloom/tasks/create_update_excursions_segments.py @@ -66,7 +66,7 @@ def add_excursion(session: Session, vessel_id: int, departure_at: datetime, total_time_fishing_in_amp=timedelta(0), total_time_fishing_in_territorial_waters=timedelta(0), total_time_fishing_in_costal_waters=timedelta(0), - total_time_extincting_amp=timedelta(0) + total_time_default_ais=timedelta(0) ) new_excursion = excursion_repository.create_excursion(session, new_excursion) return new_excursion.id @@ -303,6 +303,9 @@ def get_time_of_departure(): for segment, zones in result.items(): segment_in_zone = False for zone in zones: + if segment.type == "DEFAULT_AIS": + # Issue 234: ne pas créer les relations pour les segments en default AIS + continue segment_in_zone = True new_rels.append(RelSegmentZone(segment_id=segment.id, zone_id=zone.id)) if zone.category == "amp": @@ -321,8 +324,6 @@ def get_time_of_departure(): excursion.total_time_in_amp += segment.segment_duration elif segment.type == "FISHING": excursion.total_time_fishing_in_amp += segment.segment_duration - elif segment.type == "DEFAULT_AIS": - excursion.total_time_extincting_amp += segment.segment_duration if segment.in_costal_waters: if segment.type == "AT_SEA": excursion.total_time_in_costal_waters += segment.segment_duration @@ -337,6 +338,10 @@ def get_time_of_departure(): excursion.excursion_duration += segment.segment_duration if segment.type == "FISHING": excursion.total_time_fishing += segment.segment_duration + elif segment.type == "DEFAULT_AIS": + if excursion.total_time_default_ais is None: + excursion.total_time_default_ais = timedelta(0) + excursion.total_time_default_ais += segment.segment_duration excursion.total_time_at_sea = excursion.excursion_duration - ( excursion.total_time_in_costal_waters + excursion.total_time_in_territorial_waters) diff --git a/backend/bloom/tasks/load_fct_excursions_from_csv.py b/backend/bloom/tasks/load_fct_excursions_from_csv.py index 208deb13..e46e4d8b 100644 --- a/backend/bloom/tasks/load_fct_excursions_from_csv.py +++ b/backend/bloom/tasks/load_fct_excursions_from_csv.py @@ -71,7 +71,7 @@ def map_excursion_to_domain(row) -> Excursion: total_time_fishing_in_amp=None, total_time_fishing_in_territorial_waters=None, total_time_fishing_in_costal_waters=None, - total_time_extincting_amp=None, + total_time_default_ais=None, created_at=None, updated_at=None, )