Skip to content

fix(submit): preserve per-device cross-machine breakdowns#313

Open
IvGolovach wants to merge 3 commits intojunhoyeo:mainfrom
IvGolovach:fix-cross-machine-submit-correctness
Open

fix(submit): preserve per-device cross-machine breakdowns#313
IvGolovach wants to merge 3 commits intojunhoyeo:mainfrom
IvGolovach:fix-cross-machine-submit-correctness

Conversation

@IvGolovach
Copy link
Copy Markdown
Contributor

@IvGolovach IvGolovach commented Mar 11, 2026

Preserve per-device source breakdowns when the same user submits usage from multiple machines.

The existing merge path can overwrite a client's daily source breakdown when a different device re-submits the same day. This change stores per-device contributions inside each client bucket, replaces only the current device's contribution on re-submit, and preserves other devices.

It also migrates legacy client-only entries into a reserved __legacy__ device bucket, and reconciles days that disappear from the current device's submitted date range without touching days outside that range.

No database migration is required.

Related to #248.

Checks:

  • cd packages/frontend && ../../.bun/bin/bun x vitest run __tests__/api/submit.test.ts
  • cd packages/frontend && ../../.bun/bin/bun x vitest run
  • cd packages/frontend && ../../.bun/bin/bun x tsc --noEmit

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 11, 2026

@IvGolovach is attempting to deploy a commit to the Inevitable Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/frontend/src/app/api/submit/route.ts">

<violation number="1" location="packages/frontend/src/app/api/submit/route.ts:274">
P1: Disappeared-day reconciliation prunes only `submittedClients`, allowing stale current-device data to persist for omitted clients.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread packages/frontend/src/app/api/submit/route.ts
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