Repository navigation
refactor(tasks): simplify TaskRepository.UpdateAsync audit-event blocks (#197) - #360
Merged
Merged
Conversation
nevridge
force-pushed
the
feature/simplify-taskrepository-audit-blocks
branch
from
October 30, 2026 22:56
5c6b3ec to
582918d
Compare
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.
Closes #197
Summary
Pure refactor of
TaskRepository.UpdateAsync: the four near-identical "if changed, emit history event" blocks (Title, Priority, Description, DueDate) are replaced by one private helper,AddFieldChangedEvent(int taskId, bool changed, string eventType, Func<string> summary), placed afterFormatDueDate. Task history is unchanged for users.string.Equalsfor Title and Description,!=for Priority and DueDate.EventTypeandChangeSummarystrings are byte-identical tomain, because the frontendTaskHistoryPanelmaps them.DateTime.UtcNow.Detachedbranch is kept, with a comment explaining it is a safety net for callers that pass untracked entities. It is not removable: an existing test exercises it.Files changed
TaskFlow.Api/Repositories/TaskRepository.cs: the helper, four call sites, and the Detached comment. The read paths at the top of the file are untouched, which limits conflicts with perf(api): add AsNoTracking to read-only repository query paths (#196) #359 ([Perf] Add AsNoTracking() to read-only repository query paths #196).TaskFlow.Api.Tests/Repositories/TaskRepositoryUpdateEventTests.cs(new): 20 characterization test cases (theory rows counted). They were written and run green against the unmodified code first, then re-run after the refactor.Tests
As reported by the test-verifier (CI will run them again):
dotnet format TaskFlow.sln --verify-no-changes: exit 0dotnet build TaskFlow.sln -c Release: 0 warnings, 0 errorsNew tests cover exact summaries for each field, Priority-only, single-event assertions, ordering (including field events before the status event), the case-only Title change, an Ordinal-only Description change, null/empty Description swaps, same-value no-ops, a DueDate with a different
Kind(no event), InProgress falling through to StatusChanged, and Detached title and priority changes.Validator status
Critical 0, Important 0, Minor 1 (after one rework pass).
Residual, for awareness:
StringComparison.Ordinal.Suggested follow-up issue (not filed)
Possible missed Description/DueDate event on the Detached path when the persisted value is null. The originals use
persisted?.X ?? entry.OriginalValues..., and afterUpdate(task)the fallback already equals the incoming value. This was found by code reading and is unverified, and no production caller reaches the Detached path. This PR neither hides nor alters it, and no test asserts it. It is worth verifying and fixing separately.