Add search event reason#546
Conversation
Review Summary by QodoAdd search event reason tracking with normalized database schema and comprehensive integration tests
WalkthroughsDescription• **Refactored search event publishing** to include structured search reasons (SeekerSearchReason enum) and per-item event tracking instead of batch events • **Normalized database schema** for events by introducing SearchEventData entity with ItemTitle, SearchType, SearchReason, and GrabbedItems fields, replacing denormalized JSON storage • **Added ArrInstanceId and DownloadClientId foreign keys** to AppEvent for proper relational tracking instead of storing instance/client metadata as strings • **Refactored event publishing interfaces** - PublishSearchTriggered() now accepts individual item details with search reason; PublishSearchCompleted() accepts grabbed items list • **Enhanced download client context tracking** by adding SetDownloadClientContext() helper method and applying it across all download client implementations • **Updated API contracts** - SearchEventResponse now includes ArrInstanceId, ItemTitle, and SearchReason instead of InstanceName and item arrays • **Comprehensive integration test suite** with new IntegrationTestFixture providing real services with mocked external boundaries, covering Seeker, Striker, QueueCleaner, DownloadCleaner, and MalwareBlocker jobs • **Frontend enhancements** to display search reasons with severity badges and simplified grabbed items as string arrays • **Fixed download client context setup** in Transmission service queue check method • **Removed obsolete HTTP client provider tests** and refactored namespace imports across codebase Diagramflowchart LR
A["Search Event<br/>Publishing"] -->|"per-item with<br/>reason"| B["SearchEventData<br/>Entity"]
B -->|"structured<br/>storage"| C["Events DB<br/>Normalized"]
D["Job Handlers<br/>Seeker/Striker/<br/>QueueCleaner"] -->|"publish with<br/>ArrInstanceId"| A
E["Download Clients"] -->|"SetDownloadClientContext"| F["Context Provider"]
F -->|"track client"| A
G["API Controller"] -->|"query via<br/>ArrInstanceId"| C
G -->|"return ItemTitle<br/>& SearchReason"| H["Frontend<br/>Display"]
I["Integration Tests"] -->|"validate"| D
File Changes1. code/backend/Cleanuparr.Infrastructure.Tests/Features/Jobs/Integration/StrikerIntegrationTests.cs
|
Code Review by Qodo
1.
|
|
@greptileai review |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR adds a
Confidence Score: 4/5Not safe to merge as-is — two P1 migration issues will corrupt grabbed-item data for existing users and break future migration generation. The feature logic and refactoring are well-executed, but the migration has a data-format mismatch for GrabbedItems backfill and the snapshot is inconsistent with the dropped columns, both of which have direct runtime consequences. 20260401101043_AddSearchEventData.cs (grabbed_items backfill SQL) and EventsContextModelSnapshot.cs (stale mapped columns) Important Files Changed
Sequence DiagramsequenceDiagram
participant Seeker
participant ArrClient
participant EventPublisher
participant DB as EventsDB
participant SCM as SeekerCommandMonitor
loop For each SeekerSearchCandidate
Seeker->>ArrClient: SearchItemsAsync(arrInstance, [searchItem])
ArrClient-->>Seeker: commandIds
Seeker->>EventPublisher: PublishSearchTriggered(title, type, reason)
EventPublisher->>DB: BEGIN TRANSACTION
EventPublisher->>DB: INSERT AppEvent (SearchTriggered)
EventPublisher->>DB: INSERT SearchEventData (title, type, reason)
EventPublisher->>DB: COMMIT
EventPublisher-->>Seeker: eventId
Seeker->>DB: SaveCommandTracker(eventId, commandIds)
end
loop Poll command status
SCM->>ArrClient: GetCommandAsync(commandId)
ArrClient-->>SCM: commandStatus
end
SCM->>ArrClient: GetQueueAsync
ArrClient-->>SCM: queueRecords (grabbed titles)
SCM->>EventPublisher: PublishSearchCompleted(eventId, Completed, grabbedTitles)
EventPublisher->>DB: UPDATE AppEvent.SearchStatus = Completed
EventPublisher->>DB: UPDATE SearchEventData.GrabbedItems = [titles]
Reviews (1): Last reviewed commit: "improved Seeker process response" | Re-trigger Greptile |
01c2d36 to
fd41cb6
Compare
Relates to #524