Skip to content

Commit f021c4b

Browse files
committed
Replace legacy_ prefix with nma_
1 parent dc7a31b commit f021c4b

7 files changed

Lines changed: 184 additions & 184 deletions

File tree

db/location.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ class Location(Base, AutoBaseMixin, ReleaseMixin, NotesMixin, DataProvenanceMixi
6262
nma_notes_location: Mapped[str] = mapped_column(Text, nullable=True)
6363
nma_coordinate_notes: Mapped[str] = mapped_column(Text, nullable=True)
6464

65-
# --- Legacy AMPAPI Date Fields (Migration-Only, Read-Only Post-Migration) ---
66-
legacy_date_created: Mapped[datetime.date] = mapped_column(
65+
# --- AMPAPI Date Fields (Migration-Only, Read-Only Post-Migration) ---
66+
nma_date_created: Mapped[datetime.date] = mapped_column(
6767
Date,
6868
nullable=True,
6969
comment="Original AMPAPI DateCreated (migration-only field)",
7070
)
71-
legacy_site_date: Mapped[datetime.date] = mapped_column(
71+
nma_site_date: Mapped[datetime.date] = mapped_column(
7272
Date, nullable=True, comment="Original AMPAPI SiteDate (migration-only field)"
7373
)
7474

schemas/location.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ class GeoJSONProperties(BaseModel):
107107
default_factory=GeoJSONUTMCoordinates
108108
)
109109
notes: list[NoteResponse] = []
110-
# Legacy AMPAPI date fields (migration-only, read-only)
111-
legacy_date_created: date | None = None
112-
legacy_site_date: date | None = None
110+
# AMPAPI date fields (migration-only, read-only)
111+
nma_date_created: date | None = None
112+
nma_site_date: date | None = None
113113

114114
model_config = ConfigDict(
115115
from_attributes=True,
@@ -154,11 +154,11 @@ def populate_fields(cls, data: Any) -> Any:
154154
data_dict["properties"]["notes"] = data_dict.get("notes")
155155
data_dict["properties"]["elevation"] = convert_m_to_ft(elevation_m)
156156
data_dict["properties"]["elevation_method"] = data_dict.get("elevation_method")
157-
# populate legacy date fields
158-
data_dict["properties"]["legacy_date_created"] = data_dict.get(
159-
"legacy_date_created"
157+
# populate AMPAPI date fields
158+
data_dict["properties"]["nma_date_created"] = data_dict.get(
159+
"nma_date_created"
160160
)
161-
data_dict["properties"]["legacy_site_date"] = data_dict.get("legacy_site_date")
161+
data_dict["properties"]["nma_site_date"] = data_dict.get("nma_site_date")
162162

163163
# populate UTM coordinates
164164
point_utm_zone_13n_wkt = transform_srid(
@@ -190,9 +190,9 @@ class LocationResponse(BaseResponseModel):
190190
county: str | None
191191
quad_name: str | None
192192

193-
# Legacy AMPAPI date fields (migration-only, read-only post-migration)
194-
legacy_date_created: date | None = None
195-
legacy_site_date: date | None = None
193+
# AMPAPI date fields (migration-only, read-only post-migration)
194+
nma_date_created: date | None = None
195+
nma_site_date: date | None = None
196196

197197
@field_validator("point", mode="before")
198198
def point_to_wkt(cls, value):
@@ -232,9 +232,9 @@ class UpdateLocation(BaseUpdateModel, ValidateLocation):
232232
coordinate_accuracy: float | None = None
233233
coordinate_method: CoordinateMethod | None = None
234234

235-
# Legacy AMPAPI date fields (migration-only, can be updated but not created)
236-
legacy_date_created: date | None = None
237-
legacy_site_date: date | None = None
235+
# AMPAPI date fields (migration-only, can be updated but not created)
236+
nma_date_created: date | None = None
237+
nma_site_date: date | None = None
238238

239239

240240
# ============= EOF =============================================

tests/features/post-migration-legacy-data-retrieval.feature

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,82 +13,82 @@ Feature: Post-Migration Legacy Data Retrieval
1313
Scenario: Retrieve location with both legacy dates via API
1414
Given a location exists with:
1515
| field | value |
16-
| legacy_date_created | 2014-04-03 |
17-
| legacy_site_date | 2002-12-10 |
16+
| nma_date_created | 2014-04-03 |
17+
| nma_site_date | 2002-12-10 |
1818
When I retrieve that location via the API
19-
Then the response should include legacy_date_created as "2014-04-03"
20-
And the response should include legacy_site_date as "2002-12-10"
19+
Then the response should include nma_date_created as "2014-04-03"
20+
And the response should include nma_site_date as "2002-12-10"
2121
And the time gap should be approximately 11.3 years
2222

2323
Scenario: Retrieve location with large time gap (54 years)
2424
Given a location exists with:
2525
| field | value |
26-
| legacy_date_created | 2008-05-28 |
27-
| legacy_site_date | 1954-05-01 |
26+
| nma_date_created | 2008-05-28 |
27+
| nma_site_date | 1954-05-01 |
2828
When I retrieve that location via the API
29-
Then the response should include legacy_date_created as "2008-05-28"
30-
And the response should include legacy_site_date as "1954-05-01"
29+
Then the response should include nma_date_created as "2008-05-28"
30+
And the response should include nma_site_date as "1954-05-01"
3131
And the time gap should be approximately 54 years
3232

3333
Scenario: List all locations includes legacy date fields
3434
Given 5 locations exist with various legacy dates
3535
When I GET /location to list all locations
36-
Then each location should have a legacy_date_created field
37-
And each location should have a legacy_site_date field
38-
And some locations should have null legacy_site_date
36+
Then each location should have a nma_date_created field
37+
And each location should have a nma_site_date field
38+
And some locations should have null nma_site_date
3939

4040
Scenario: Filter locations by legacy site date range
41-
Given locations exist with legacy_site_date ranging from 1950 to 2024
42-
When I filter locations where legacy_site_date is between "2000-01-01" and "2010-12-31"
43-
Then the response should only include locations with legacy_site_date in that decade
44-
And locations with legacy_site_date before 2000 should not be included
45-
And locations with legacy_site_date after 2010 should not be included
41+
Given locations exist with nma_site_date ranging from 1950 to 2024
42+
When I filter locations where nma_site_date is between "2000-01-01" and "2010-12-31"
43+
Then the response should only include locations with nma_site_date in that decade
44+
And locations with nma_site_date before 2000 should not be included
45+
And locations with nma_site_date after 2010 should not be included
4646

47-
Scenario: Query location by legacy_date_created
48-
Given 3 locations exist with legacy_date_created "2014-04-03"
49-
And 2 locations exist with legacy_date_created "2017-12-06"
50-
When I query for locations with legacy_date_created "2014-04-03"
47+
Scenario: Query location by nma_date_created
48+
Given 3 locations exist with nma_date_created "2014-04-03"
49+
And 2 locations exist with nma_date_created "2017-12-06"
50+
When I query for locations with nma_date_created "2014-04-03"
5151
Then the response should include exactly 3 locations
52-
And all should have legacy_date_created "2014-04-03"
52+
And all should have nma_date_created "2014-04-03"
5353

5454
# Data Quality Validation
5555

5656
Scenario: Verify migration preserved expected percentage of legacy dates
5757
Given 100 locations were migrated
5858
And 9 of them had non-null SiteDate in AMPAPI
5959
When I query the migrated locations
60-
Then 9% should have non-null legacy_site_date
61-
And 100% should have non-null legacy_date_created
60+
Then 9% should have non-null nma_site_date
61+
And 100% should have non-null nma_date_created
6262

6363
# Audit Trail Verification
6464

6565
Scenario: Legacy dates preserved alongside audit timestamps
6666
Given a location was migrated with legacy dates
6767
When I retrieve that location
6868
Then it should have created_at (new system timestamp from migration)
69-
And it should have legacy_date_created (original AMPAPI DateCreated)
70-
And it should have legacy_site_date (original AMPAPI SiteDate)
69+
And it should have nma_date_created (original AMPAPI DateCreated)
70+
And it should have nma_site_date (original AMPAPI SiteDate)
7171
And all three timestamps should be independently queryable
7272
And created_at should be a recent timestamp
73-
And legacy_date_created should be an older date
73+
And nma_date_created should be an older date
7474

7575
# Edge Cases
7676

7777
Scenario: Location where SiteDate is later than DateCreated (data anomaly)
7878
Given a location exists with:
7979
| field | value |
80-
| legacy_date_created | 2010-01-15 |
81-
| legacy_site_date | 2015-06-20 |
80+
| nma_date_created | 2010-01-15 |
81+
| nma_site_date | 2015-06-20 |
8282
When I retrieve that location
83-
Then legacy_date_created should be "2010-01-15"
84-
And legacy_site_date should be "2015-06-20"
83+
Then nma_date_created should be "2010-01-15"
84+
And nma_site_date should be "2015-06-20"
8585
And the system should accept this without error
8686

87-
Scenario: Location with only legacy_date_created (no legacy_site_date)
87+
Scenario: Location with only nma_date_created (no nma_site_date)
8888
Given a location exists with:
8989
| field | value |
90-
| legacy_date_created | 2014-10-17 |
91-
| legacy_site_date | null |
90+
| nma_date_created | 2014-10-17 |
91+
| nma_site_date | null |
9292
When I retrieve that location
93-
Then legacy_date_created should be "2014-10-17"
94-
And legacy_site_date should be null
93+
Then nma_date_created should be "2014-10-17"
94+
And nma_site_date should be null

0 commit comments

Comments
 (0)