Add mount_count and unmount_count tracking for samples
Introduced `mount_count` and `unmount_count` fields to track mounting events for samples. Updated models, schemas, and front-end components to support dynamic calculation and display of these counts. Enhanced backend queries and API responses to include the new data.
This commit is contained in:
@ -151,6 +151,16 @@ class Sample(Base):
|
||||
puck = relationship("Puck", back_populates="samples")
|
||||
events = relationship("SampleEvent", back_populates="sample")
|
||||
|
||||
@property
|
||||
def mount_count(self) -> int:
|
||||
# Dynamically calculate mount_count
|
||||
return len([event for event in self.events if event.event_type == "Mounted"])
|
||||
|
||||
@property
|
||||
def unmount_count(self) -> int:
|
||||
# Dynamically calculate unmount_count
|
||||
return len([event for event in self.events if event.event_type == "Unmounted"])
|
||||
|
||||
|
||||
class Slot(Base):
|
||||
__tablename__ = "slots"
|
||||
|
Reference in New Issue
Block a user