Skip to content

Feat/suggestion bundling - #5

Open
tomasvanrijsse wants to merge 10 commits into
mainfrom
feat/suggestion-bundling
Open

Feat/suggestion bundling#5
tomasvanrijsse wants to merge 10 commits into
mainfrom
feat/suggestion-bundling

Conversation

@tomasvanrijsse

Copy link
Copy Markdown
Contributor

No description provided.

Wrap the destructive sequence (detach → forceDelete → rebundle) in a
database transaction to prevent data loss if bundle() throws mid-operation.
Previously, if an error occurred during rebundling, suggestions would already
be deleted and activities left with entry_suggestion_id = null, unrecoverable
by re-run.

Claude
Mocks SuggestionBundler::bundle to throw mid-transaction and asserts
the detach/forceDelete work is rolled back, not just the bundle call.
Suggestion and activity IDs were plucked before the transaction opened,
so a concurrently queued CreateSuggestion listener could attach an
activity to a doomed suggestion after the snapshot but before the
detach/forceDelete, orphaning it to the entry_suggestion_id ON DELETE
CASCADE. Lock the suggestions with lockForUpdate() and take both
snapshots inside the transaction, and detach activities by suggestion
ID instead of a pre-plucked activity ID list.
newSuggestionFromActivity() assigned a full Carbon datetime to
EntrySuggestion::$date while findMatchingSuggestion() compares
against suggestionDateFor()'s toDateString(); the match only worked
because MySQL silently truncates the DATE column. Write the same
date string that is used for matching, and update the model's
@Property annotation for date to ?string to match.
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