now with a working countdowntimer for each dewar

This commit is contained in:
GotthardG
2024-11-20 22:37:18 +01:00
parent cacf43b631
commit db610da588
7 changed files with 162 additions and 82 deletions

View File

@ -143,19 +143,11 @@ class Slot(Base):
qr_base = Column(String, nullable=True)
occupied = Column(Boolean, default=False)
needs_refill = Column(Boolean, default=False)
last_refill = Column(DateTime, default=datetime.utcnow)
time_until_refill = Column(Integer) # store as total seconds
dewar_name = Column(String) # Ensure this field exists
dewar_unique_id = Column(String, ForeignKey('dewars.unique_id'), nullable=True) # Added field
dewar = relationship("Dewar", back_populates="slot")
events = relationship("LogisticsEvent", back_populates="slot")
@property
def calculate_time_until_refill(self):
if self.last_refill and self.time_until_refill:
return self.last_refill + self.time_until_refill - datetime.utcnow()
return None
class LogisticsEvent(Base):
__tablename__ = "logistics_events"