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:
@ -149,7 +149,7 @@ class Sample(Base):
|
||||
dewar_id = Column(Integer, ForeignKey("dewars.id"))
|
||||
puck_id = Column(Integer, ForeignKey("pucks.id"))
|
||||
puck = relationship("Puck", back_populates="samples")
|
||||
events = relationship("SampleEvent", back_populates="sample")
|
||||
events = relationship("SampleEvent", back_populates="sample", lazy="joined")
|
||||
|
||||
@property
|
||||
def mount_count(self) -> int:
|
||||
@ -183,7 +183,7 @@ class LogisticsEvent(Base):
|
||||
dewar_id = Column(Integer, ForeignKey("dewars.id"))
|
||||
slot_id = Column(Integer, ForeignKey("slots.id"))
|
||||
event_type = Column(String(255), index=True)
|
||||
timestamp = Column(DateTime, default=datetime.utcnow)
|
||||
timestamp = Column(DateTime, default=datetime.now)
|
||||
dewar = relationship("Dewar", back_populates="events")
|
||||
slot = relationship("Slot", back_populates="events")
|
||||
|
||||
@ -192,9 +192,9 @@ class SampleEvent(Base):
|
||||
__tablename__ = "sample_events"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
sample_id = Column(Integer, ForeignKey("samples.id"))
|
||||
event_type = Column(String(255), index=True)
|
||||
timestamp = Column(DateTime, default=datetime.utcnow)
|
||||
sample_id = Column(Integer, ForeignKey("samples.id"), nullable=False)
|
||||
event_type = Column(String(255), nullable=False)
|
||||
timestamp = Column(DateTime, default=datetime.now)
|
||||
|
||||
sample = relationship("Sample", back_populates="events")
|
||||
|
||||
@ -206,6 +206,6 @@ class PuckEvent(Base):
|
||||
puck_id = Column(Integer, ForeignKey("pucks.id"))
|
||||
tell_position = Column(String(255), nullable=True)
|
||||
event_type = Column(String(255), index=True)
|
||||
timestamp = Column(DateTime, default=datetime.utcnow)
|
||||
timestamp = Column(DateTime, default=datetime.now)
|
||||
|
||||
puck = relationship("Puck", back_populates="events")
|
||||
|
Reference in New Issue
Block a user