Skip to content

fix: preserve pieceId during deal creation#439

Merged
silent-cipher merged 5 commits intomainfrom
refactor/deal-piece-id
Apr 21, 2026
Merged

fix: preserve pieceId during deal creation#439
silent-cipher merged 5 commits intomainfrom
refactor/deal-piece-id

Conversation

@silent-cipher
Copy link
Copy Markdown
Collaborator

@silent-cipher silent-cipher commented Apr 9, 2026

Summary

These changes address pieceId preservation issues. uploadResult is often missing pieceId, so we preserve it from the piecesConfirmed event. This is important for cleaning up pieces later on.

Problem

Missing pieceId while testing locally -

Select count(*) from deals where status = 'deal_created' and piece_id is null;
 count 
-------
    25
(1 row)

Select count(*) from deals where status = 'deal_created';
 count 
-------
    68
(1 row)

Copilot AI review requested due to automatic review settings April 9, 2026 06:21
@FilOzzy FilOzzy added this to FOC Apr 9, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Apr 9, 2026
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 updates the backend deal-creation flow to better preserve pieceId when executeUpload() returns an uploadResult without it, using the onPiecesConfirmed progress event as a fallback so later piece cleanup remains possible.

Changes:

  • Capture pieceId from the onPiecesConfirmed upload progress event (fallback source).
  • Avoid overwriting an already-set deal.pieceId with a missing uploadResult.pieceId.
  • Update unit test typings to model pieceIds as bigint[] and emit a bigint in the mocked progress event.

Reviewed changes

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

File Description
apps/backend/src/deal/deal.service.ts Sets deal.pieceId during onPiecesConfirmed and preserves it when uploadResult.pieceId is nullish.
apps/backend/src/deal/deal.service.spec.ts Adjusts mocked upload progress event typing/data to use bigint[] for pieceIds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/backend/src/deal/deal.service.ts
Comment thread apps/backend/src/deal/deal.service.ts Outdated
Comment thread apps/backend/src/deal/deal.service.spec.ts
@silent-cipher silent-cipher requested a review from SgtPooki April 10, 2026 05:55
@BigLep BigLep moved this from 📌 Triage to 🔎 Awaiting review in FOC Apr 10, 2026
Comment thread apps/backend/src/deal/deal.service.ts
@silent-cipher silent-cipher merged commit 814a23b into main Apr 21, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this from 🔎 Awaiting review to 🎉 Done in FOC Apr 21, 2026
@silent-cipher silent-cipher deleted the refactor/deal-piece-id branch April 21, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

5 participants