Skip to content

refactor: rename upload_failed to offline_synced and name the slot windows - #354

Merged
Victor1Ja merged 1 commit into
stagingfrom
feat/rename-offline-synced-and-slot-names
Aug 25, 2026
Merged

refactor: rename upload_failed to offline_synced and name the slot windows#354
Victor1Ja merged 1 commit into
stagingfrom
feat/rename-offline-synced-and-slot-names

Conversation

@Victor1Ja

@Victor1Ja Victor1Ja commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to the review comment on #349 (posted after that PR merged). Both naming changes, no behaviour change.

1. upload_failedoffline_synced

By the time the row exists the upload succeeded — it just came in through the offline sync queue rather than the realtime path. upload_failed reads like the record is bad or incomplete when the data is fine; offline_synced describes how it arrived.

  • schema.prisma: offline_synced Boolean? @default(false)
  • measurement.dto.ts: offline_synced?: boolean + updated @ApiProperty description
  • measurement.service.ts: both toModel() and the DTO mapping (offline_synced: measurement.offline_synced ?? false)
  • mock-objects.ts, measurement.service.spec.ts: renamed

2. Slot codes A/B/C → time-of-day names

The slots are fixed windows, so the letters throw away meaning that is already there. Self-documenting in the DB, in the API docs and in dashboard queries.

Old Window New
A 8:00 AM – 12:00 PM morning
B 12:00 PM – 4:00 PM afternoon
C 4:00 PM+ evening
startup daily launch startup (unchanged)

scheduled_slot stays varchar(16), still null for manual runs. Descriptions updated in schema.prisma, measurement.dto.ts and the test that used to send 'A'.

Migration: forward-only

The review comment suggested editing 20260807120000_add_upload_failed_and_schedule_context in place. That migration is left byte-identical here instead, because it already merged to staging on 2026-08-18 and any environment that has applied it would otherwise fail its checksum and try to re-add columns that already exist.

The rename is a new migration, 20260824120000_rename_upload_failed_to_offline_synced:

ALTER TABLE "measurements" RENAME COLUMN "upload_failed" TO "offline_synced";

UPDATE "measurements" SET "scheduled_slot" = 'morning'   WHERE "scheduled_slot" = 'A';
UPDATE "measurements" SET "scheduled_slot" = 'afternoon' WHERE "scheduled_slot" = 'B';
UPDATE "measurements" SET "scheduled_slot" = 'evening'   WHERE "scheduled_slot" = 'C';

RENAME COLUMN preserves existing values and the DEFAULT false. The three UPDATEs rewrite the slot codes already written by the RC builds so the column does not end up with a mix of letters and names — drop them if you would rather leave the existing staging rows as they are. startup and NULL are untouched. Safe to run on an environment that has the old migration and on one that does not.

Testing

  • npx jest444 passed, 63 suites, no regressions.
  • npx tsc --noEmit clean.
  • npx prisma generate clean.
  • prettier --check on the touched files reports only violations that are already present on staging (measurement.service.spec.ts, mock-objects.ts); left alone to keep the diff readable.

Still to land

The frontend counterpart (unicef/project-connect-daily-check-app#83) writes these values and needs the same rename at the same time. The contract doc project-memory/api-contracts/measurements-v1.md and the v2.0.4 plan are updated separately (they live outside this repo).

🤖 Generated with Claude Code

…ndows

Review follow-up on #349.

upload_failed reads as if the record is bad, but by the time the row
exists the upload succeeded - it just arrived through the offline sync
queue instead of the realtime path. offline_synced describes how the
record arrived rather than implying a failure.

scheduled_slot moves from the opaque codes 'A'/'B'/'C' to the windows
they already stand for: 'morning' (8:00-12:00), 'afternoon' (12:00-16:00)
and 'evening' (16:00+). 'startup' is unchanged and null still means a
manual run. Still fits varchar(16).

Forward-only migration: 20260807120000_add_upload_failed_and_schedule_context
is left byte-identical, so environments that already applied it keep
their checksum and their rows. The new
20260824120000_rename_upload_failed_to_offline_synced does an
ALTER TABLE ... RENAME COLUMN (values and default preserved) and rewrites
the three existing slot codes in place.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Victor1Ja
Victor1Ja merged commit 9a6b57c into staging Aug 25, 2026
1 check 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.

2 participants