Skip to content

feat(reports): note updates + report regeneration queue - #79

Merged
CropWatchDevelopment merged 2 commits into
masterfrom
develop
Jul 25, 2026
Merged

CropWatchDevelopment merged 2 commits into
masterfrom
develop

Conversation

@CropWatchDevelopment

Copy link
Copy Markdown
Owner

Server side of report note editing: users annotate an already-generated report's data points and the report PDF is regenerated by CW-Reports on its next scheduled cron run (stored next to the original, never re-emailed).

  • PATCH /v1/air/notes/:note_id — wires the previously-unused UpdateAirAnnotationDto. Service whitelists {title, note, include_in_report} only: the PartialType DTO also admits dev_eui/created_at and an update must never re-point a note at another device's reading.
  • POST /v1/reports/:id/regenerate — queues a row in the new cw_report_regeneration_queue after validating: template visibility (404 via findOne), device is assigned, manage-tier permission (listManagedDevices + assertDevicesCanBeManaged), sane period (<= 62 days, end within the 23-month retention window — data lives 24 months and regen can lag a cron cycle), and path-safe sourceObjectName. Dedupe: at most one pending row per (template, device, period), enforced by a partial unique index; repeated saves re-touch it and accumulate edit_count; the 23505 insert race resolves to the winner's row.
  • GET /v1/reports/:id/regenerations — pending/processing rows for the template; the frontend history dialog badges affected reports with the accumulated edit count.
  • devices.service findDataWithinRange now joins cw_air_annotations + cw_air_alerts for air devices (parity with findData) so period reads carry their notes.
  • supabase/updates/016_report_regeneration_queue.sql (+ idempotent edit_count addendum) — already hand-run on prod; README run-order updated. Regenerate database.types.ts in api + CropWatch when convenient.

Route-contract snapshot updated (PATCH air note). New specs cover the note whitelist, regeneration validation branches, dedupe, and the unique-index race.

Server side of report note editing: users annotate an already-generated
report's data points and the report PDF is regenerated by CW-Reports on its
next scheduled cron run (stored next to the original, never re-emailed).

- PATCH /v1/air/notes/:note_id — wires the previously-unused
  UpdateAirAnnotationDto. Service whitelists {title, note, include_in_report}
  only: the PartialType DTO also admits dev_eui/created_at and an update must
  never re-point a note at another device's reading.
- POST /v1/reports/:id/regenerate — queues a row in the new
  cw_report_regeneration_queue after validating: template visibility (404
  via findOne), device is assigned, manage-tier permission
  (listManagedDevices + assertDevicesCanBeManaged), sane period (<= 62 days,
  end within the 23-month retention window — data lives 24 months and regen
  can lag a cron cycle), and path-safe sourceObjectName. Dedupe: at most one
  pending row per (template, device, period), enforced by a partial unique
  index; repeated saves re-touch it and accumulate edit_count; the 23505
  insert race resolves to the winner's row.
- GET /v1/reports/:id/regenerations — pending/processing rows for the
  template; the frontend history dialog badges affected reports with the
  accumulated edit count.
- devices.service findDataWithinRange now joins cw_air_annotations +
  cw_air_alerts for air devices (parity with findData) so period reads carry
  their notes.
- supabase/updates/016_report_regeneration_queue.sql (+ idempotent
  edit_count addendum) — already hand-run on prod; README run-order updated.
  Regenerate database.types.ts in api + CropWatch when convenient.

Route-contract snapshot updated (PATCH air note). New specs cover the note
whitelist, regeneration validation branches, dedupe, and the unique-index
race.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api Ready Ready Preview, Comment Jul 25, 2026 3:53pm

Request Review

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@CropWatchDevelopment
CropWatchDevelopment merged commit b88ff2c into master Jul 25, 2026
5 checks passed
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.

1 participant