From 0841dffafe54ca8066f9d3a82a4e5a19c08eac2c Mon Sep 17 00:00:00 2001 From: Joachim Meyer Date: Thu, 12 Jun 2025 10:03:10 -0600 Subject: [PATCH 1/3] Schema - Remove `comments` from layer_data Dropping the column in favor of making it a measurement_type, where the value holds the information. GH-188 --- snowexsql/tables/layer_data.py | 1 - tests/factories/layer_data.py | 2 -- tests/tables/test_layer_data.py | 3 --- 3 files changed, 6 deletions(-) diff --git a/snowexsql/tables/layer_data.py b/snowexsql/tables/layer_data.py index 677bbf79..169f2315 100644 --- a/snowexsql/tables/layer_data.py +++ b/snowexsql/tables/layer_data.py @@ -17,7 +17,6 @@ class LayerData(HasMeasurementType, HasInstrument, Base): depth = Column(Float, nullable=False, index=True) bottom_depth = Column(Float) - comments = Column(Text) value = Column(Text, nullable=False, index=True) # Link the site id with a foreign key diff --git a/tests/factories/layer_data.py b/tests/factories/layer_data.py index f96090bc..9e0cbbfb 100644 --- a/tests/factories/layer_data.py +++ b/tests/factories/layer_data.py @@ -19,7 +19,6 @@ class Meta: depth = 100.0 bottom_depth = 90.0 - comments = 'Layer comment' value = '40' measurement_type = factory.SubFactory( @@ -41,7 +40,6 @@ class LayerDensityFactory(LayerDataFactory): depth = 15.0 bottom_depth = 5.0 value = '236.0' - comments = 'Sample_A' site = factory.SubFactory( SiteFactory, diff --git a/tests/tables/test_layer_data.py b/tests/tables/test_layer_data.py index 56f8bb0e..b86057cf 100644 --- a/tests/tables/test_layer_data.py +++ b/tests/tables/test_layer_data.py @@ -28,9 +28,6 @@ def test_bottom_depth_attribute(self): assert type(self.subject.bottom_depth) is float assert self.subject.bottom_depth == self.attributes.bottom_depth - def test_comments_attribute(self): - assert self.subject.comments == self.attributes.comments - def test_value_attribute(self): assert self.subject.value == self.attributes.value From 1fa28e7be6158700d16c7145037a1e66286cab59 Mon Sep 17 00:00:00 2001 From: Joachim Meyer Date: Thu, 12 Jun 2025 10:04:07 -0600 Subject: [PATCH 2/3] Schema - Add `comments` to site Adding a text `comments` column to hold the information that is on the top right of every pit sheet. GH-188 --- snowexsql/tables/site.py | 5 ++++- tests/factories/site.py | 2 ++ tests/tables/test_site.py | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/snowexsql/tables/site.py b/snowexsql/tables/site.py index a5779ef7..16013284 100644 --- a/snowexsql/tables/site.py +++ b/snowexsql/tables/site.py @@ -1,7 +1,7 @@ from typing import List from sqlalchemy import ( - Column, Date, Float, ForeignKey, Integer, String, Index + Column, Date, Float, ForeignKey, Index, Integer, String, Text ) from sqlalchemy.ext.hybrid import hybrid_property from sqlalchemy.orm import Mapped, mapped_column, relationship @@ -37,6 +37,9 @@ class Site(SingleLocationData, Base, InCampaign, HasDOI): name = Column(String(), nullable=False) # This can be pit_id description = Column(String()) + # Example: Top right comment section on a pit sheet + comments = Column(Text) + # Link the observer # id is a mapped column for many-to-many with observers id: Mapped[int] = mapped_column(primary_key=True) diff --git a/tests/factories/site.py b/tests/factories/site.py index f70e291a..3b6ab2dc 100644 --- a/tests/factories/site.py +++ b/tests/factories/site.py @@ -17,6 +17,8 @@ class Meta: description = 'Site Description' datetime = factory.LazyFunction(lambda: datetime.now(timezone.utc)) + comments = "Observer comment on site" + slope_angle = 0.0 aspect = 0.0 air_temp = -5.0 diff --git a/tests/tables/test_site.py b/tests/tables/test_site.py index 6e1c6cc0..6d895a83 100644 --- a/tests/tables/test_site.py +++ b/tests/tables/test_site.py @@ -107,6 +107,11 @@ def test_elevation_attribute(self, point_data_factory): def test_geom_attribute(self): assert isinstance(self.subject.geom, WKBElement) + def test_comments_attribute(self): + assert self.subject.comments == self.attributes.comments + + # Relationships + # ------------- def test_in_campaign(self): assert self.subject.campaign is not None assert isinstance(self.subject.campaign, Campaign) From cc96a044b84dfbbb48ec9f560946f5ddc178011a Mon Sep 17 00:00:00 2001 From: Joachim Meyer Date: Wed, 18 Jun 2025 10:29:45 -0600 Subject: [PATCH 3/3] Schema - Site - Drop 'Site Notes' column in favor of comment Both are representing the same information, the top right comments box. Using the 'comments' to be more descriptive (as I have personally forgotten that we had it on the table already) --- snowexsql/tables/site.py | 7 +++---- tests/factories/site.py | 4 +--- tests/tables/test_site.py | 3 --- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/snowexsql/tables/site.py b/snowexsql/tables/site.py index 16013284..ef89436f 100644 --- a/snowexsql/tables/site.py +++ b/snowexsql/tables/site.py @@ -37,9 +37,6 @@ class Site(SingleLocationData, Base, InCampaign, HasDOI): name = Column(String(), nullable=False) # This can be pit_id description = Column(String()) - # Example: Top right comment section on a pit sheet - comments = Column(Text) - # Link the observer # id is a mapped column for many-to-many with observers id: Mapped[int] = mapped_column(primary_key=True) @@ -61,7 +58,9 @@ class Site(SingleLocationData, Base, InCampaign, HasDOI): ground_vegetation = Column(String()) vegetation_height = Column(String()) tree_canopy = Column(String()) - site_notes = Column(String()) + # Example: Top right comment section on a pit sheet + comments = Column(Text) + # Relationships layer_data = relationship('LayerData', lazy='joined') diff --git a/tests/factories/site.py b/tests/factories/site.py index 3b6ab2dc..975fc833 100644 --- a/tests/factories/site.py +++ b/tests/factories/site.py @@ -17,8 +17,6 @@ class Meta: description = 'Site Description' datetime = factory.LazyFunction(lambda: datetime.now(timezone.utc)) - comments = "Observer comment on site" - slope_angle = 0.0 aspect = 0.0 air_temp = -5.0 @@ -32,7 +30,7 @@ class Meta: ground_vegetation = "Bare" vegetation_height = "None" tree_canopy = "Open" - site_notes = "Site Notes" + comments = "Observer comment on site" # Single Location data geom = WKTElement( diff --git a/tests/tables/test_site.py b/tests/tables/test_site.py index 6d895a83..28b2162e 100644 --- a/tests/tables/test_site.py +++ b/tests/tables/test_site.py @@ -98,9 +98,6 @@ def test_vegetation_height_attribute(self): def test_tree_canopy_attribute(self): assert self.subject.tree_canopy == self.attributes.tree_canopy - def test_site_notes_attribute(self): - assert self.subject.site_notes == self.attributes.site_notes - def test_elevation_attribute(self, point_data_factory): assert self.subject.elevation == point_data_factory.elevation