Fix MacDive waypoint gas switches (M1.5)#253
Conversation
There was a problem hiding this comment.
Pull request overview
This PR closes a UDDF import gap for MacDive exports where deco gas changes are encoded as waypoint-level <switchmix ref="mix-id"/> (gas-mix UUID) rather than tank UUIDs, ensuring those switches persist into gas_switches with correct tank_id resolution.
Changes:
- UDDF parser now emits waypoint
<switchmix ref>markers intodiveData['gasSwitches'](withgasMixRef) and recordsuddfGasMixRefon tanks for lookup. - UDDF entity importer now resolves gas switches by either
tankRef(tank UUID) orgasMixRef(gas-mix UUID) to a persisted tank row id. - Adds/updates unit + integration tests to verify end-to-end persistence and real-sample coverage for
diveData['gasSwitches'].
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/core/services/export/uddf/uddf_full_import_service.dart | Emit waypoint-level gas switches, record uddfGasMixRef on tanks, and merge/dedupe gas switch sources. |
| lib/features/dive_import/data/services/uddf_entity_importer.dart | Resolve imported gas switches to dive_tanks by either tank UUID or gas-mix UUID. |
| test/core/services/export/uddf/uddf_macdive_import_test.dart | Updates unit coverage to assert gasSwitches emission (instead of sample-level gasMixRef). |
| test/core/services/export/uddf/uddf_macdive_real_sample_test.dart | Updates real-sample regression check to look for gasSwitches entries. |
| test/features/dive_import/macdive_waypoint_gas_switch_test.dart | New integration test validating gas switches persist to DB with correct tank mapping. |
Addresses Copilot review feedback on PR #253: - tankdata mixRef is now trimmed before being stored as uddfGasMixRef, so whitespace-only refs don't become non-resolvable identifiers downstream. - waypoint <switchmix ref> is trimmed and skipped when empty, so gasSwitches entries the importer couldn't resolve to a tank are never emitted. - Integration test identifies tanks by o2Percent (32% bottom / 80% deco) instead of relying on SQLite/Drift row order, removing cross-version flakiness.
Addresses Copilot review feedback on PR #253: - tankdata mixRef is now trimmed before being stored as uddfGasMixRef, so whitespace-only refs don't become non-resolvable identifiers downstream. - waypoint <switchmix ref> is trimmed and skipped when empty, so gasSwitches entries the importer couldn't resolve to a tank are never emitted. - Integration test identifies tanks by o2Percent (32% bottom / 80% deco) instead of relying on SQLite/Drift row order, removing cross-version flakiness.
2148f7e to
8e30a74
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes a UDDF import gap for MacDive exports where gas switches are encoded as waypoint-level <switchmix ref="mix-uuid"/> references (gas-mix UUIDs) rather than <gasswitches> tank refs, ensuring those switches now persist correctly into the gas_switches table.
Changes:
- UDDF parser now emits waypoint
<switchmix ref>markers intodiveData['gasSwitches'](withgasMixRef) and recordsuddfGasMixRefon tank maps for later resolution. - UDDF importer now resolves gas switch
tankIdvia eithertankRef(existing path) orgasMixRef(MacDive path). - Adds/updates unit + integration tests to cover parser emission and end-to-end DB persistence of MacDive waypoint gas switches.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/features/dive_import/macdive_waypoint_gas_switch_test.dart | New integration test validating waypoint <switchmix> gas switches persist to gas_switches with correct tank_id. |
| test/core/services/export/uddf/uddf_macdive_real_sample_test.dart | Updates real-sample regression assertion to check diveData['gasSwitches'] instead of sample-level gasMixRef. |
| test/core/services/export/uddf/uddf_macdive_import_test.dart | Replaces placeholder test with one asserting gasSwitches emission from waypoint <switchmix ref> for multi-tank dives. |
| lib/features/dive_import/data/services/uddf_entity_importer.dart | Extends gas switch resolution to support gasMixRef → tank mapping via tanks’ uddfGasMixRef. |
| lib/core/services/export/uddf/uddf_full_import_service.dart | Records uddfGasMixRef on tanks; emits/merges waypoint-derived gasSwitches entries (trimmed, skip empty refs, dedupe). |
f8994f0 to
90b3c44
Compare
…tches pipe MacDive marks gas changes using <switchmix ref="gas-UUID"/> inside individual waypoint samples. The parser previously recorded this on the sample map (point['gasMixRef']) but it went nowhere; the importer resolves gas switches via tankRef, but MacDive's switchmix ref is a gas-mix UUID, not a tank UUID. Parser now emits gas switches into diveData['gasSwitches'] with gasMixRef (alongside the existing tankRef-from-top-level-<gasswitches> path), deduping timestamp|gasMixRef|tankRef so both sources feed one consumer. Tanks also record uddfGasMixRef so the downstream importer can resolve gas-mix UUID -> tank id. Importer now resolves both tankRef and gasMixRef to tankId, so single-pipe persistence works for both source-level and waypoint-level switch markers. Adds unit test for parser emission, integration test verifying gas_switches rows land on the correct dive_tanks rows, and updates the MacDive real-sample regression to assert gasSwitches entries rather than the now-removed sample-level gasMixRef. Closes the parser-to-DB gap noted as a known limitation in M1.
Addresses Copilot review feedback on PR #253: - tankdata mixRef is now trimmed before being stored as uddfGasMixRef, so whitespace-only refs don't become non-resolvable identifiers downstream. - waypoint <switchmix ref> is trimmed and skipped when empty, so gasSwitches entries the importer couldn't resolve to a tank are never emitted. - Integration test identifies tanks by o2Percent (32% bottom / 80% deco) instead of relying on SQLite/Drift row order, removing cross-version flakiness.
8e30a74 to
cbde25f
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
<switchmix ref="gas-UUID"/>markers intodiveData['gasSwitches']withgasMixRef, feeding the same consumer as the top-level<gasswitches>pipe (deduped ontimestamp|gasMixRef|tankRef).uddfGasMixRefso the downstream importer can resolve the gas-mix UUID back to adive_tanksrow.tankReforgasMixRefto a tank id, closing the parser-to-DB gap flagged as a known limitation in M1.Why
MacDive writes deco gas changes as sample-level
<switchmix ref="mix-deco"/>where the ref points at a<gasdefinitions><mix id="...">UUID (not a<tankdata id="...">UUID). The parser was already reading these markers but only stashing them on the profile sample aspoint['gasMixRef'], where no downstream consumer read them. The<gasswitches>importer path that already persists to thegas_switchestable only resolvedtankRef, so MacDive's gas switches were silently dropped between parser and DB.Test plan
test/core/services/export/uddf/uddf_macdive_import_test.dart"emits gasSwitches from waypoint <switchmix ref> for multi-tank dives"test/features/dive_import/macdive_waypoint_gas_switch_test.dartverifies gas_switches rows land on correct dive_tanks rows end-to-endgasMixReftest replaced with agasSwitches-emission test (sample-level assignment was the Task 9 placeholder with no downstream consumer)diveData['gasSwitches']on the 540-dive MacDive sampledart formatclean,flutter analyzeclean,flutter test7113 pass / 5 gated