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:
GotthardG
2025-01-20 11:02:56 +01:00
parent 3d804c1635
commit 3b315f2997
4 changed files with 56 additions and 13 deletions

View File

@ -13,6 +13,8 @@ interface Sample {
crystalname?: string;
positioninpuck?: number;
events: Event[];
mount_count: number; // Add this
unmount_count: number; // Add this
}
interface Puck {
@ -32,6 +34,8 @@ const SampleTracker: React.FC = () => {
const fetchPucks = async () => {
try {
const data: Puck[] = await SamplesService.getAllPucksWithSamplesAndEventsSamplesPucksSamplesGet();
console.log('Fetched Pucks:', data); // Check for dynamic mount_count and unmount_count
setPucks(data);
} catch (error) {
console.error('Error fetching pucks', error);
@ -110,12 +114,29 @@ const SampleTracker: React.FC = () => {
border: sample && sample.events.some((e) => e.event_type === 'Lost')
? '1px solid red'
: '1px solid lightgray',
position: 'relative', // Add for overlay positioning
}}
onMouseEnter={() =>
sample && setHoveredSample({ name: sample.sample_name, status })
}
onMouseLeave={() => setHoveredSample(null)}
></div>
>
{sample && sample.mount_count > 0 && ( // Render only if mount_count > 0
<span
style={{
position: 'absolute',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
color: 'white',
fontSize: '8px',
fontWeight: 'bold',
}}
>
{sample.mount_count}
</span>
)}
</div>
);
})}
</div>