Feat/suggestion bundling - #5
Open
tomasvanrijsse wants to merge 10 commits into
Open
Conversation
…ct ticket matching
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.