Add endpoints and logic for fetching associations by beamtime
Introduced endpoints to fetch pucks, dewars, and samples by beamtime ID. Updated backend logic to ensure consistency between dewars, pucks, and samples assignments. Enhanced frontend to display and handle beamline-specific associations dynamically.
This commit is contained in:
@ -682,9 +682,16 @@ dewar_to_beamtime = {
|
||||
dewar.id: random.choice([1, 2]) for dewar in dewars # Or use actual beamtime ids
|
||||
}
|
||||
|
||||
# Update dewars and their pucks with consistent beamtime
|
||||
for dewar in dewars:
|
||||
dewar.beamtime_id = dewar_to_beamtime[dewar.id]
|
||||
|
||||
for puck in pucks:
|
||||
dewar_id = puck.dewar_id # Assuming puck has dewar_id
|
||||
assigned_beamtime = dewar_to_beamtime[dewar_id]
|
||||
puck.beamtime_id = (
|
||||
assigned_beamtime # Associate puck to the same beamtime as its dewar
|
||||
)
|
||||
|
||||
positions_with_samples = random.randint(1, 16)
|
||||
occupied_positions = random.sample(range(1, 17), positions_with_samples)
|
||||
@ -696,7 +703,7 @@ for puck in pucks:
|
||||
sample_name=f"Sample{sample_id_counter:03}",
|
||||
position=pos,
|
||||
puck_id=puck.id,
|
||||
beamtime_id=assigned_beamtime, # IMPORTANT: Use the dewar's beamtime
|
||||
beamtime_id=assigned_beamtime,
|
||||
)
|
||||
samples.append(sample)
|
||||
sample_id_counter += 1
|
||||
|
Reference in New Issue
Block a user