Skip to content

Fix MacDive waypoint gas switches (M1.5)#253

Merged
ericgriffin merged 2 commits into
mainfrom
feature/macdive-gasmix-switches
Apr 23, 2026
Merged

Fix MacDive waypoint gas switches (M1.5)#253
ericgriffin merged 2 commits into
mainfrom
feature/macdive-gasmix-switches

Conversation

@ericgriffin
Copy link
Copy Markdown
Member

Summary

  • Parser now emits waypoint <switchmix ref="gas-UUID"/> markers into diveData['gasSwitches'] with gasMixRef, feeding the same consumer as the top-level <gasswitches> pipe (deduped on timestamp|gasMixRef|tankRef).
  • Tanks record uddfGasMixRef so the downstream importer can resolve the gas-mix UUID back to a dive_tanks row.
  • Importer extended to resolve either tankRef or gasMixRef to 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 as point['gasMixRef'], where no downstream consumer read them. The <gasswitches> importer path that already persists to the gas_switches table only resolved tankRef, so MacDive's gas switches were silently dropped between parser and DB.

Test plan

  • New unit test: test/core/services/export/uddf/uddf_macdive_import_test.dart "emits gasSwitches from waypoint <switchmix ref> for multi-tank dives"
  • New integration test: test/features/dive_import/macdive_waypoint_gas_switch_test.dart verifies gas_switches rows land on correct dive_tanks rows end-to-end
  • Existing sample-level gasMixRef test replaced with a gasSwitches-emission test (sample-level assignment was the Task 9 placeholder with no downstream consumer)
  • Real-sample regression test updated to check diveData['gasSwitches'] on the 540-dive MacDive sample
  • dart format clean, flutter analyze clean, flutter test 7113 pass / 5 gated

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 into diveData['gasSwitches'] (with gasMixRef) and records uddfGasMixRef on tanks for lookup.
  • UDDF entity importer now resolves gas switches by either tankRef (tank UUID) or gasMixRef (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.

Comment thread test/features/dive_import/macdive_waypoint_gas_switch_test.dart Outdated
Comment thread lib/core/services/export/uddf/uddf_full_import_service.dart
Comment thread lib/core/services/export/uddf/uddf_full_import_service.dart
@ericgriffin ericgriffin mentioned this pull request Apr 22, 2026
7 tasks
ericgriffin added a commit that referenced this pull request Apr 22, 2026
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.
ericgriffin added a commit that referenced this pull request Apr 22, 2026
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.
Copilot AI review requested due to automatic review settings April 22, 2026 05:30
@ericgriffin ericgriffin force-pushed the feature/macdive-gasmix-switches branch from 2148f7e to 8e30a74 Compare April 22, 2026 05:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 into diveData['gasSwitches'] (with gasMixRef) and records uddfGasMixRef on tank maps for later resolution.
  • UDDF importer now resolves gas switch tankId via either tankRef (existing path) or gasMixRef (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).

@ericgriffin ericgriffin moved this from Backlog to In review in Submersion Release Tracker Apr 22, 2026
@ericgriffin ericgriffin self-assigned this Apr 22, 2026
@ericgriffin ericgriffin force-pushed the feature/macdive-uddf-gap-fill branch from f8994f0 to 90b3c44 Compare April 23, 2026 01:35
Base automatically changed from feature/macdive-uddf-gap-fill to main April 23, 2026 02:14
…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.
@ericgriffin ericgriffin force-pushed the feature/macdive-gasmix-switches branch from 8e30a74 to cbde25f Compare April 23, 2026 02:23
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ericgriffin ericgriffin merged commit ea020e6 into main Apr 23, 2026
16 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in Submersion Release Tracker Apr 23, 2026
@ericgriffin ericgriffin deleted the feature/macdive-gasmix-switches branch April 23, 2026 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants