-
Notifications
You must be signed in to change notification settings - Fork 4
BDMS-115 Sensor model updates #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c72ba26
docs: Clarify purpose of the `Sensor` table.
ksmuczynski 63e7bc7
refactor: Add/remove fields from the `Sensor` model.
ksmuczynski a1f4bf5
feat: Add `sensor_type` category and valid values to lexicon.
ksmuczynski 6f633d3
refactor: Update lexicon.json
ksmuczynski e5d38b2
refactor: Update tests
ksmuczynski 5433ee9
refactor: Update tests
ksmuczynski 4e046c5
Merge branch 'staging' into kas-sensor-model-update-20251008
ksmuczynski 39a7088
refactor: Update 'get_sensors' endpoint
ksmuczynski 0d7f530
refactor: Update Sensor schemas
ksmuczynski 85fa239
refactor: Update tests
ksmuczynski c045549
refactor: Uncomment PATCH endpoint
ksmuczynski a41f1f4
Merge branch 'kas-sensor-model-update-20251008' of https://github.com…
jacob-a-brown e5d0e00
feat: transfer sensors and deployments
jacob-a-brown File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,13 +13,15 @@ | |
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # =============================================================================== | ||
| from datetime import datetime | ||
| """ | ||
| SQLAlchemy model for the Sensor table. | ||
| """ | ||
|
|
||
| from sqlalchemy import String, Integer, DateTime | ||
| from sqlalchemy import String, Text | ||
| from sqlalchemy.ext.associationproxy import AssociationProxy, association_proxy | ||
| from sqlalchemy.orm import relationship, mapped_column, Mapped | ||
|
|
||
| from db.base import Base, AutoBaseMixin, ReleaseMixin | ||
| from db.base import Base, AutoBaseMixin, ReleaseMixin, lexicon_term | ||
|
|
||
| from typing import List, TYPE_CHECKING | ||
|
|
||
|
|
@@ -31,22 +33,54 @@ | |
|
|
||
| class Sensor(Base, AutoBaseMixin, ReleaseMixin): | ||
| """ | ||
| Base class for all sensor types. | ||
| The `Sensor` table serves as the central asset inventory for all physical hardware used for data collection. | ||
| Its purpose is to track each unique piece of equipment as a distinct asset. | ||
|
|
||
| This table is distinct from the `AnalysisMethod` table, as it deals exclusively with tangible, physical objects. | ||
|
|
||
| This class can be extended to create specific sensor types. | ||
| """ | ||
|
|
||
| # Define common attributes for sensors here | ||
| # --- Columns --- | ||
| nma_pk_equipment: Mapped[str] = mapped_column( | ||
| String(36), | ||
| nullable=True, | ||
| comment="Preserves the primary key (GlobalID) of the Equipment table from NMAquifer.", | ||
| ) | ||
| # TODO: Is a name field necessary? If it is, we should consider standardizing naming conventions. | ||
| name: Mapped[str] = mapped_column(String(255), nullable=False) | ||
| model: Mapped[str] = mapped_column(String(50), nullable=True) | ||
| serial_no: Mapped[str] = mapped_column(String(50), nullable=True) | ||
| datetime_installed: Mapped[datetime] = mapped_column( | ||
| DateTime(timezone=True), nullable=False | ||
| sensor_type: Mapped[str] = lexicon_term( | ||
| nullable=False, | ||
| comment="A controlled vocabulary field to categorize the equipment (e.g., 'Pressure Transducer', 'Barometer', 'Data Logger', etc).", | ||
| ) | ||
| model: Mapped[str] = mapped_column( | ||
| String(50), nullable=True, comment="The specific model of the equipment." | ||
| ) | ||
| serial_no: Mapped[str] = mapped_column( | ||
| String(50), | ||
| nullable=True, | ||
| unique=True, | ||
| comment="The serial number of the equipment.", | ||
| ) | ||
| # TODO: What data type should `pcn_number` be? Should it be a string or integer? | ||
| pcn_number: Mapped[str] = mapped_column( | ||
| String(50), | ||
| nullable=True, | ||
| unique=True, | ||
| comment="The Property Control Number (PCN) assigned to equipment for inventory tracking. This is only available for equipment owned by the NMBGMR.", | ||
| ) | ||
| owner_agency: Mapped[str] = lexicon_term( | ||
| nullable=True, comment="The agency or organization that owns the equipment." | ||
| ) | ||
| sensor_status: Mapped[str] = lexicon_term( | ||
| nullable=True, | ||
| comment="A controlled vocabulary field to indicate the current status of the equipment (e.g., 'In Service', 'In Repair', 'Retired', 'Lost', etc).", | ||
|
Comment on lines
+75
to
+77
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this something that goes in the |
||
| ) | ||
| datetime_removed: Mapped[datetime] = mapped_column( | ||
| DateTime(timezone=True), nullable=True | ||
| notes: Mapped[str] = mapped_column( | ||
| Text, | ||
| nullable=True, | ||
| comment="A field for general notes or comments about the equipment.", | ||
| ) | ||
| recording_interval: Mapped[int] = mapped_column(Integer, nullable=True) | ||
| notes: Mapped[str] = mapped_column(String(50), nullable=True) | ||
|
|
||
| # --- Relationships --- | ||
| # One-To-Many: A piece of Equipment can generate many Observations. | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these query parameters are now present in this endpoint we should make tests to ensure they work as expected and to safeguard future development.