diff --git a/admin/views/deployment.py b/admin/views/deployment.py index 867655ba8..511b69356 100644 --- a/admin/views/deployment.py +++ b/admin/views/deployment.py @@ -51,6 +51,12 @@ class DeploymentAdmin(OcotilloModelView): "recording_interval", "release_status", "created_at", + "nma_WI_Duration", + "nma_WI_EndFrequency", + "nma_WI_Magnitude", + "nma_WI_MicGain", + "nma_WI_MinSoundDepth", + "nma_WI_StartFrequency", ] fields_default_sort = [ @@ -65,6 +71,12 @@ class DeploymentAdmin(OcotilloModelView): "recording_interval_units", "release_status", "created_at", + "nma_WI_Duration", + "nma_WI_EndFrequency", + "nma_WI_Magnitude", + "nma_WI_MicGain", + "nma_WI_MinSoundDepth", + "nma_WI_StartFrequency", ] page_size = 50 @@ -85,6 +97,12 @@ class DeploymentAdmin(OcotilloModelView): "hanging_point_height", "hanging_point_description", "notes", + "nma_WI_Duration", + "nma_WI_EndFrequency", + "nma_WI_Magnitude", + "nma_WI_MicGain", + "nma_WI_MinSoundDepth", + "nma_WI_StartFrequency", # Release Status "release_status", # Audit Fields diff --git a/alembic/versions/263109252fb1_add_legacy_equipment_fields.py b/alembic/versions/263109252fb1_add_legacy_equipment_fields.py new file mode 100644 index 000000000..35d8166b0 --- /dev/null +++ b/alembic/versions/263109252fb1_add_legacy_equipment_fields.py @@ -0,0 +1,46 @@ +"""add legacy equipment fields + +Revision ID: 263109252fb1 +Revises: c1d2e3f4a5b6 +Create Date: 2026-01-28 10:05:10.122531 + +""" + +from typing import Sequence, Union + +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision: str = "263109252fb1" +down_revision: Union[str, Sequence[str], None] = "3a9c1f5b7d2e" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None +FIELDS = ( + "WI_Duration", + "WI_EndFrequency", + "WI_Magnitude", + "WI_MicGain", + "WI_MinSoundDepth", + "WI_StartFrequency", +) + + +def upgrade() -> None: + """Upgrade schema.""" + + for field in FIELDS: + op.add_column( + "deployment", + sa.Column( + f"nma_{field}", + sa.Integer(), + nullable=True, + ), + ) + + +def downgrade() -> None: + """Downgrade schema.""" + for field in FIELDS: + op.drop_column("deployment", f"nma_{field}") diff --git a/db/deployment.py b/db/deployment.py index 0b2dc61df..20c4e8651 100644 --- a/db/deployment.py +++ b/db/deployment.py @@ -46,6 +46,13 @@ class Deployment(Base, AutoBaseMixin, ReleaseMixin): hanging_point_description: Mapped[str] = mapped_column(Text, nullable=True) notes: Mapped[str] = mapped_column(Text, nullable=True) + nma_WI_Duration: Mapped[int] = mapped_column(Integer, nullable=True) + nma_WI_EndFrequency: Mapped[int] = mapped_column(Integer, nullable=True) + nma_WI_Magnitude: Mapped[int] = mapped_column(Integer, nullable=True) + nma_WI_MicGain: Mapped[int] = mapped_column(Integer, nullable=True) + nma_WI_MinSoundDepth: Mapped[int] = mapped_column(Integer, nullable=True) + nma_WI_StartFrequency: Mapped[int] = mapped_column(Integer, nullable=True) + # --- Relationships --- # Many-To-One: A Deployment is for one Thing. thing: Mapped["Thing"] = relationship("Thing", back_populates="deployments") diff --git a/transfers/sensor_transfer.py b/transfers/sensor_transfer.py index 3a39a1a03..91d5f8475 100644 --- a/transfers/sensor_transfer.py +++ b/transfers/sensor_transfer.py @@ -218,6 +218,12 @@ def _group_step(self, session: Session, row: pd.Series, db_item: Base): hanging_cable_length=row.HangingCableLength, hanging_point_height=row.HangingPointHgt, hanging_point_description=row.HangingPointDescription, + nma_WI_Duration=row.WI_Duration, + nma_WI_EndFrequency=row.WI_EndFrequency, + nma_WI_Magnitude=row.WI_Magnitude, + nma_WI_MicGain=row.WI_MicGain, + nma_WI_MinSoundDepth=row.WI_MinSoundDepth, + nma_WI_StartFrequency=row.WI_StartFrequency, ) session.add(deployment) logger.info(