Skip to content

Advance report cursor after empty scans - #108

Merged
bkeepers merged 2 commits into
mainfrom
fix/advance-empty-scan-checkpoint
Aug 8, 2026
Merged

Advance report cursor after empty scans#108
bkeepers merged 2 commits into
mainfrom
fix/advance-empty-scan-checkpoint

Conversation

@bkeepers

@bkeepers bkeepers commented Aug 8, 2026

Copy link
Copy Markdown
Member

What changed

Crowd Depth now records progress after a history scan completes with no bathymetry points. Batch scans also advance past empty windows once the full range has been inspected.

Previously, only a successful submission moved the cursor. When the boat produced no new soundings, every scheduled run queried the entire empty period again. That made the InfluxDB history queries grow on each cycle and occasionally contend with live telemetry writes.

Failed reads, failed submissions, and aborted scans still leave the cursor untouched so they will retry. The plugin status now says "Checked through" because the timestamp can represent either a submission or a completed empty scan.

Tests

  • 69 tests pass
  • TypeScript build and package validation pass
  • Formatting and lint checks pass

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 8, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
crowd-depth-api e7b8d17 Commit Preview URL

Branch Preview URL
Aug 08 2026, 05:02 PM

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates the Signal K plugin’s reporting cursor semantics so progress is recorded not only after successful submissions, but also after scans that complete with no bathymetry points (including batch scans), reducing repeated history reads over empty ranges.

Changes:

  • Advance the report cursor after a scan completes with no data, and after batch scans finish inspecting the full range (including empty windows).
  • Update plugin status wording from “Reported at …” to “Checked through …”.
  • Extend tests to cover checkpoint behavior (empty scans, batch scans, read failures, and aborted batch scans).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/signalk-plugin/src/reporters/index.ts Adds checkpointing for empty scans and after batch scans; refactors checkpoint logic into a helper and returns reporter methods.
packages/signalk-plugin/src/status.ts Updates status message wording to “Checked through …”.
packages/signalk-plugin/test/helper.ts Extends test app stub to include setPluginError used by status error handling.
packages/signalk-plugin/test/reporter.test.ts Adds tests validating cursor advancement behavior across empty scans, batch scans, failures, and aborts.
Suppressed comments (2)

packages/signalk-plugin/src/reporters/index.ts:113

  • The end-of-range checkpoint in reportInBatches() can still run if the signal is aborted right after the last window is processed (between the loop and this block). Add an abort guard here so aborted batch scans never record progress.
      !reportLog.lastReport ||
      Temporal.Instant.compare(reportLog.lastReport, timeframe.to) < 0
    ) {
      checkpoint(timeframe);
    }

packages/signalk-plugin/src/reporters/index.ts:71

  • report() checkpoints immediately after a successful submission without checking signal.aborted. If the plugin is stopped during submission, the cursor may still advance; guard checkpoint() so aborted runs do not record progress.
      const submission = await submitGeoJSON(url, config, vessel, data);
      app.debug("Submission response: %j", submission);
      checkpoint(timeframe);
    } catch (err) {

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/signalk-plugin/src/reporters/index.ts
Comment thread packages/signalk-plugin/src/reporters/index.ts
@bkeepers
bkeepers merged commit 3b58fc9 into main Aug 8, 2026
3 checks passed
@bkeepers
bkeepers deleted the fix/advance-empty-scan-checkpoint branch August 8, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants