Skip to content

Commit f380299

Browse files
committed
Add tables needed to record information relevant to email notifications
1 parent 1dd1c29 commit f380299

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/murfey/util/db.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,10 @@ class DataCollectionGroup(SQLModel, table=True): # type: ignore
360360
back_populates="data_collection_group",
361361
sa_relationship_kwargs={"cascade": "delete"},
362362
)
363+
notification_parameters: List["NotificationParameter"] = Relationship(
364+
back_populates="data_collection_group",
365+
sa_relationship_kwargs={"cascade": "delete"},
366+
)
363367
tomography_preprocessing_parameters: List["TomographyPreprocessingParameters"] = (
364368
Relationship(
365369
back_populates="data_collection_group",
@@ -368,6 +372,34 @@ class DataCollectionGroup(SQLModel, table=True): # type: ignore
368372
)
369373

370374

375+
class NotificationParameter(SQLModel, table=True): # type: ignore
376+
id: int = Field(primary_key=True, unique=True)
377+
dcg_id: int = Field(foreign_key="datacollectiongroup.id", primary_key=True)
378+
name: str
379+
min_value: float
380+
max_value: float
381+
num_instances_since_triggered: int = 0
382+
notification_active: bool = False
383+
data_collection_group: Optional[DataCollectionGroup] = Relationship(
384+
back_populates="notification_parameters"
385+
)
386+
notification_values: List["NotificationValue"] = Relationship(
387+
back_populates="notification_parameter",
388+
sa_relationship_kwargs={"cascade": "delete"},
389+
)
390+
391+
392+
class NotificationValue(SQLModel, table=True): # type: ignore
393+
id: int = Field(primary_key=True, unique=True)
394+
notification_parameter_id: int = Field(
395+
foreign_key="notificationparameter.id", primary_key=True
396+
)
397+
index: int
398+
notification_parameter: Optional[DataCollectionGroup] = Relationship(
399+
back_populates="notification_values"
400+
)
401+
402+
371403
class DataCollection(SQLModel, table=True): # type: ignore
372404
id: int = Field(primary_key=True, unique=True)
373405
tag: str = Field(primary_key=True)

0 commit comments

Comments
 (0)