now associating a dewar to a slot

This commit is contained in:
GotthardG
2024-11-19 13:43:54 +01:00
parent 48fd2c3a7c
commit fa1e9c86b8
4 changed files with 41 additions and 18 deletions

View File

@ -86,6 +86,7 @@ class Dewar(Base):
dewar_type = relationship("DewarType")
dewar_serial_number = relationship("DewarSerialNumber")
slot = relationship("Slot", back_populates="dewar")
@property
def number_of_pucks(self) -> int:
@ -144,6 +145,9 @@ class Slot(Base):
needs_refill = Column(Boolean, default=False)
last_refill = Column(DateTime, default=datetime.utcnow)
time_until_refill = Column(Integer) # store as total seconds
dewar_unique_id = Column(String, ForeignKey('dewars.unique_id'), nullable=True) # Added field
dewar = relationship("Dewar", back_populates="slot")
@property
def calculate_time_until_refill(self):
@ -151,6 +155,7 @@ class Slot(Base):
return self.last_refill + self.time_until_refill - datetime.utcnow()
return None
class LogisticsEvent(Base):
__tablename__ = 'logistics_events'
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
@ -158,4 +163,5 @@ class LogisticsEvent(Base):
event_type = Column(String, nullable=False)
timestamp = Column(DateTime, default=datetime.utcnow)
dewar = relationship("Dewar", back_populates="events")
dewar = relationship("Dewar", back_populates="events")
slot_id = Column(String, ForeignKey('slots.id'), nullable=True)