changed models and schemasa
This commit is contained in:
@ -69,11 +69,13 @@ class Dewar(Base):
|
||||
|
||||
@property
|
||||
def number_of_pucks(self) -> int:
|
||||
return calculate_number_of_pucks(self)
|
||||
return len(self.pucks) if self.pucks else 0
|
||||
|
||||
@property
|
||||
def number_of_samples(self) -> int:
|
||||
return calculate_number_of_samples(self)
|
||||
if not self.pucks:
|
||||
return 0
|
||||
return sum(len(puck.samples) for puck in self.pucks)
|
||||
|
||||
|
||||
class Proposal(Base):
|
||||
@ -88,20 +90,24 @@ class Proposal(Base):
|
||||
class Puck(Base):
|
||||
__tablename__ = 'pucks'
|
||||
|
||||
id = Column(String, primary_key=True)
|
||||
puck_name = Column(String)
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
puck_name = Column(String, index=True)
|
||||
puck_type = Column(String)
|
||||
puck_location_in_dewar = Column(Integer)
|
||||
dewar_id = Column(Integer, ForeignKey('dewars.id')) # Note: changed to String
|
||||
|
||||
positions = relationship("Sample", back_populates="puck")
|
||||
dewar = relationship("Dewar", back_populates="pucks")
|
||||
# Foreign keys and relationships
|
||||
dewar_id = Column(Integer, ForeignKey('dewars.id'))
|
||||
dewar = relationship("Dewar", back_populates="pucks") # Properly define the other side of the relationship
|
||||
samples = relationship("Sample", back_populates="puck")
|
||||
|
||||
|
||||
class Sample(Base):
|
||||
__tablename__ = 'samples'
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
sample_name = Column(String)
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
sample_name = Column(String, index=True) # Matches `sample_name` in data creation
|
||||
position = Column(Integer) # Matches `position` in data creation script
|
||||
|
||||
# Foreign keys and relationships
|
||||
puck_id = Column(Integer, ForeignKey('pucks.id'))
|
||||
puck = relationship("Puck", back_populates="positions")
|
||||
puck = relationship("Puck", back_populates="samples")
|
||||
|
Reference in New Issue
Block a user