mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-09-30 11:12:35 +02:00
A single plate dispatched from a multi-plate 3MF could log the entire file's filament against that one plate. When the AMS tracker measured nothing, a completed run's PrintLogEntry.filament_used_grams fell back to PrintArchive.filament_used_grams -- the sum over every plate (correct for the archive card / project rollup, #1593) -- ignoring the archive's plate_id. So each printed plate of a 22-plate file logged the full ~12 kg; cost inherited the same whole-file value. Forward: when the archive has a plate_id and its 3MF is on disk, the completed- run fallback uses that plate's own slicer estimate (extract_plate_metadata_from_3mf) and scales cost by the plate's share of the whole. Tracker-measured runs and single-plate archives are unchanged. Backfill: a startup migration repairs rows already written -- completed entries whose stored grams exactly equal the archive's whole-file value, with a plate_id and an on-disk 3MF, get recomputed to plate-scoped grams + cost. The exact-match guard never touches tracker-measured or partial rows; idempotent, data-only, identical on SQLite and Postgres, and logs the correction.