Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
52f60c7
refactor: Use UUID types for GlobalID/WellID in NMA_WaterLevelsContin…
ksmuczynski Jan 28, 2026
e46ac15
feat: add admin view for legacy continuous pressure daily water levels
ksmuczynski Jan 28, 2026
3cd8c56
refactor (test): Update test_waterlevelscontinuous_pressure_daily_leg…
ksmuczynski Jan 28, 2026
9b8a398
Formatting changes
ksmuczynski Jan 28, 2026
91d3aa5
fix: add ForeignKey constraint to well_id in nma_legacy model
ksmuczynski Jan 29, 2026
f09a67d
fix: update well_id to be non-optional and enforce ForeignKey constra…
ksmuczynski Jan 29, 2026
71899fe
fix: remove well_id field from NMA_HydraulicsData model
ksmuczynski Jan 29, 2026
5c7b730
fix: update well_id field to be optional and add thing_id ForeignKey …
ksmuczynski Jan 29, 2026
0ff8926
fix: make well_id field optional in nma_legacy model
ksmuczynski Jan 29, 2026
8d16b93
test: add tests for thing_id foreign key integrity in water levels co…
ksmuczynski Jan 29, 2026
3011301
Merge branch 'staging' into kas-bdms-500-admin-view-WLContinuousDaily
ksmuczynski Jan 29, 2026
d6fb0fa
feat: Add thing_id FK to NMA pressure daily table
ksmuczynski Jan 29, 2026
8ae5bbb
refactor: Enhance transfer of waterlevelscontinuous_pressure_daily
ksmuczynski Jan 29, 2026
4466e5a
feat: Add missing relationship/backref between Thing and NMA_WaterLev…
ksmuczynski Jan 29, 2026
a1f00e1
feat: enhance logging configuration and improve transfer flag handling
jirhiker Jan 30, 2026
1946357
Merge branch 'staging' into BDMS-520-1-1-Cleanup-2.0
jirhiker Jan 30, 2026
fc4adfb
Merge remote-tracking branch 'origin/kas-bdms-500-admin-view-WLContin…
jirhiker Jan 30, 2026
e0056e8
feat: add thing_id foreign key and relationship to NMA legacy model; …
jirhiker Jan 30, 2026
46c09e2
Merge branch 'staging' into BDMS-520-1-1-Cleanup-2.0
jirhiker Jan 31, 2026
0eaefb1
Formatting changes
jirhiker Jan 31, 2026
4a56b0b
feat: refactor Thing ID caching and add nma_WCLab_ID to NMA_MinorTrac…
jirhiker Jan 31, 2026
29ccb14
feat: improve cache access and refactor WCLab_ID handling in minor_tr…
jirhiker Jan 31, 2026
2df1241
fix: ensure cache initialization in minor_trace_chemistry_transfer
jirhiker Jan 31, 2026
4b07213
feat: initialize sample_info_cache and errors in MinorTraceChemistryT…
jirhiker Jan 31, 2026
104571c
Update transfers/transfer.py
jirhiker Jan 31, 2026
eccce9b
Update transfers/minor_trace_chemistry_transfer.py
jirhiker Jan 31, 2026
c862a94
refactor: streamline cache access in minor_trace_chemistry_transfer
jirhiker Jan 31, 2026
1ba2c73
Update tests/test_minor_trace_chemistry_transfer.py
jirhiker Jan 31, 2026
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
9 changes: 9 additions & 0 deletions admin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
SurfaceWaterPhotosAdmin,
ThingAdmin,
TransducerObservationAdmin,
WaterLevelsContinuousPressureDailyAdmin,
WeatherPhotosAdmin,
WeatherDataAdmin,
FieldParametersAdmin,
Expand Down Expand Up @@ -80,6 +81,7 @@
NMA_Soil_Rock_Results,
NMA_Stratigraphy,
NMA_SurfaceWaterData,
NMA_WaterLevelsContinuous_Pressure_Daily,
NMA_WeatherPhotos,
NMA_SurfaceWaterPhotos,
NMA_WeatherData,
Expand Down Expand Up @@ -192,6 +194,13 @@ def create_admin(app):
# Transducer observations
admin.add_view(TransducerObservationAdmin(TransducerObservation))

# Water Levels - Continuous (legacy)
admin.add_view(
WaterLevelsContinuousPressureDailyAdmin(
NMA_WaterLevelsContinuous_Pressure_Daily
)
)

# Weather
admin.add_view(WeatherPhotosAdmin(NMA_WeatherPhotos))

Expand Down
4 changes: 4 additions & 0 deletions admin/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
from admin.views.surface_water_photos import SurfaceWaterPhotosAdmin
from admin.views.thing import ThingAdmin
from admin.views.transducer_observation import TransducerObservationAdmin
from admin.views.waterlevelscontinuous_pressure_daily import (
WaterLevelsContinuousPressureDailyAdmin,
)
from admin.views.weather_photos import WeatherPhotosAdmin
from admin.views.weather_data import WeatherDataAdmin

Expand Down Expand Up @@ -88,6 +91,7 @@
"SurfaceWaterPhotosAdmin",
"ThingAdmin",
"TransducerObservationAdmin",
"WaterLevelsContinuousPressureDailyAdmin",
"WeatherPhotosAdmin",
"WeatherDataAdmin",
]
148 changes: 148 additions & 0 deletions admin/views/waterlevelscontinuous_pressure_daily.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# ===============================================================================
# Copyright 2026
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ===============================================================================
"""
WaterLevelsContinuousPressureDailyAdmin view for legacy NMA_WaterLevelsContinuous_Pressure_Daily.
"""

from starlette.requests import Request

from admin.views.base import OcotilloModelView


class WaterLevelsContinuousPressureDailyAdmin(OcotilloModelView):
"""
Admin view for NMA_WaterLevelsContinuous_Pressure_Daily model.
"""

# ========== Basic Configuration ==========
name = "NMA Water Levels Continuous Pressure Daily"
label = "NMA Water Levels Continuous Pressure Daily"
icon = "fa fa-tachometer-alt"

def can_create(self, request: Request) -> bool:
return False

def can_edit(self, request: Request) -> bool:
return False

def can_delete(self, request: Request) -> bool:
return False

# ========== List View ==========
list_fields = [
"global_id",
"object_id",
"well_id",
"point_id",
"date_measured",
"temperature_water",
"water_head",
"water_head_adjusted",
"depth_to_water_bgs",
"measurement_method",
"data_source",
"measuring_agency",
"qced",
"notes",
"created",
"updated",
"processed_by",
"checked_by",
"cond_dl_ms_cm",
]

sortable_fields = [
"global_id",
"object_id",
"well_id",
"point_id",
"date_measured",
"water_head",
"depth_to_water_bgs",
"measurement_method",
"data_source",
"measuring_agency",
"qced",
"created",
"updated",
"processed_by",
"checked_by",
"cond_dl_ms_cm",
]

fields_default_sort = [("date_measured", True)]

searchable_fields = [
"global_id",
"well_id",
"point_id",
"date_measured",
"measurement_method",
"data_source",
"measuring_agency",
"notes",
]

page_size = 50
page_size_options = [25, 50, 100, 200]

# ========== Detail View ==========
fields = [
"global_id",
"object_id",
"well_id",
"point_id",
"date_measured",
"temperature_water",
"water_head",
"water_head_adjusted",
"depth_to_water_bgs",
"measurement_method",
"data_source",
"measuring_agency",
"qced",
"notes",
"created",
"updated",
"processed_by",
"checked_by",
"cond_dl_ms_cm",
]

field_labels = {
"global_id": "GlobalID",
"object_id": "OBJECTID",
"well_id": "WellID",
"point_id": "PointID",
"date_measured": "Date Measured",
"temperature_water": "Temperature Water",
"water_head": "Water Head",
"water_head_adjusted": "Water Head Adjusted",
"depth_to_water_bgs": "Depth To Water (BGS)",
"measurement_method": "Measurement Method",
"data_source": "Data Source",
"measuring_agency": "Measuring Agency",
"qced": "QCed",
"notes": "Notes",
"created": "Created",
"updated": "Updated",
"processed_by": "Processed By",
"checked_by": "Checked By",
"cond_dl_ms_cm": "CONDDL (mS/cm)",
}


# ============= EOF =============================================
13 changes: 11 additions & 2 deletions alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,27 @@

from alembic import context
from dotenv import load_dotenv
from services.util import get_bool_env
from sqlalchemy import create_engine, engine_from_config, pool, text

from services.util import get_bool_env

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
alembic_logger = logging.getLogger("alembic.env")

# Interpret the config file for Python logging.
# This line sets up loggers basically.
if config.config_file_name is not None:
if config.config_file_name is not None and os.environ.get(
"ALEMBIC_USE_FILE_CONFIG", "0"
) not in {"0", "false", "False"}:
fileConfig(config.config_file_name, disable_existing_loggers=False)
else:
root_logger = logging.getLogger()
alembic_logger = logging.getLogger("alembic")
alembic_logger.handlers = root_logger.handlers[:]
alembic_logger.setLevel(root_logger.level)
alembic_logger.propagate = False

# add your model's MetaData object here
# for 'autogenerate' support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@

from typing import Sequence, Union

from alembic import op
import geoalchemy2
import sqlalchemy as sa
import sqlalchemy_utils
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
Expand Down Expand Up @@ -509,15 +507,13 @@ def upgrade() -> None:
existing_type=sa.VARCHAR(),
comment="To audit the original NM_Aquifer LocationID if it was transferred over",
existing_nullable=True,
autoincrement=False,
)
op.alter_column(
"thing_version",
"nma_formation_zone",
existing_type=sa.VARCHAR(length=25),
comment="Raw FormationZone value from legacy WellData (NM_Aquifer).",
existing_nullable=True,
autoincrement=False,
)
op.alter_column(
"transducer_observation",
Expand Down Expand Up @@ -558,7 +554,6 @@ def downgrade() -> None:
comment=None,
existing_comment="Raw FormationZone value from legacy WellData (NM_Aquifer).",
existing_nullable=True,
autoincrement=False,
)
op.alter_column(
"thing_version",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
"""merge_migrations_after_staging_merge

Revision ID: 43bc34504ee6
Revises: 3cb924ca51fd, e123456789ab
Revises: 3cb924ca51fd
Create Date: 2026-01-30 11:52:41.932306

"""

from typing import Sequence, Union

from alembic import op
import geoalchemy2
import sqlalchemy as sa
import sqlalchemy_utils

# revision identifiers, used by Alembic.
revision: str = "43bc34504ee6"
down_revision: Union[str, Sequence[str], None] = ("3cb924ca51fd", "e123456789ab")
down_revision: Union[str, Sequence[str], None] = "3cb924ca51fd"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Add unique index for NGWMN well construction

Revision ID: 50d1c2a3b4c5
Revises: 43bc34504ee6
Create Date: 2026-01-31 00:27:12.204176

"""

from typing import Sequence, Union

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "50d1c2a3b4c5"
down_revision: Union[str, Sequence[str], None] = "43bc34504ee6"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


INDEX_NAME = "uq_ngwmn_wc_point_casing_screen"
TABLE_NAME = "NMA_view_NGWMN_WellConstruction"


def upgrade() -> None:
op.create_index(
INDEX_NAME,
TABLE_NAME,
["PointID", "CasingTop", "ScreenTop"],
unique=True,
)


def downgrade() -> None:
op.drop_index(INDEX_NAME, table_name=TABLE_NAME)
29 changes: 29 additions & 0 deletions alembic/versions/71a4c6b3d2e8_add_nma_wclab_id_to_minor_trace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Add nma_WCLab_ID column to NMA_MinorTraceChemistry

Revision ID: 71a4c6b3d2e8
Revises: 50d1c2a3b4c5
Create Date: 2026-01-31 01:05:00.000000

"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision: str = "71a4c6b3d2e8"
down_revision: Union[str, Sequence[str], None] = "50d1c2a3b4c5"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
op.add_column(
"NMA_MinorTraceChemistry",
sa.Column("nma_WCLab_ID", sa.String(length=25), nullable=True),
)


def downgrade() -> None:
op.drop_column("NMA_MinorTraceChemistry", "nma_WCLab_ID")
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""enforce_thing_fk_for_nma_legacy_models

Revision ID: 76e3ae8b99cb
Revises: c1d2e3f4a5b6
Revises: e123456789ab
Create Date: 2026-01-26 11:56:28.744603

Issue: #363
Expand All @@ -17,12 +17,12 @@

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision: str = "76e3ae8b99cb"
down_revision: Union[str, Sequence[str], None] = "c1d2e3f4a5b6"
down_revision: Union[str, Sequence[str], None] = "e123456789ab"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None

Expand Down
4 changes: 2 additions & 2 deletions alembic/versions/e123456789ab_add_observation_data_quality.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""add nma_data_quality to observation

Revision ID: e123456789ab
Revises: b12e3919077e
Revises: f0c9d8e7b6a5
Create Date: 2026-02-05 12:00:00.000000

"""
Expand All @@ -13,7 +13,7 @@

# revision identifiers, used by Alembic.
revision: str = "e123456789ab"
down_revision: Union[str, Sequence[str], None] = "b12e3919077e"
down_revision: Union[str, Sequence[str], None] = "f0c9d8e7b6a5"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None

Expand Down
Loading
Loading