Fix duplicated grabbed items reported for Sonarr on season packs#549
Conversation
Review Summary by QodoFix duplicate grabbed items for Sonarr season packs
WalkthroughsDescription• Eliminates duplicate grabbed items in Sonarr season pack tracking • Groups queue records by DownloadId and selects first occurrence • Prevents duplicate reporting when processing season pack downloads Diagramflowchart LR
A["Queue Records"] -- "Filter by ItemType & IDs" --> B["Filtered Records"]
B -- "GroupBy DownloadId" --> C["Grouped Records"]
C -- "Select First from Each Group" --> D["Deduplicated Records"]
D -- "Map to Result Objects" --> E["Unique Grabbed Items"]
File Changes1. code/backend/Cleanuparr.Infrastructure/Features/Jobs/SeekerCommandMonitor.cs
|
|
@sourcery-ai review |
Code Review by Qodo
1.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR fixes a bug where Sonarr season packs were reported as multiple grabbed items — one per episode — rather than a single grab. The root cause is that Sonarr creates one
Confidence Score: 5/5Safe to merge — the fix is minimal, surgical, and logically correct with no regression risk. Two-line LINQ addition on a non-nullable required field. The deduplication logic is straightforward and has no edge cases that would cause incorrect behaviour compared to the pre-fix code. No files require special attention; the change is confined to a single LINQ chain in SeekerCommandMonitor.cs. Important Files Changed
Sequence DiagramsequenceDiagram
participant SCM as SeekerCommandMonitor
participant Arr as ArrClient
participant LINQ as LINQ Pipeline
SCM->>Arr: GetQueueItemsAsync(instance, page=1)
Arr-->>SCM: QueueListResponse (N records)
Note over SCM,LINQ: For each tracker (Sonarr season pack)
SCM->>LINQ: .Where(SeriesId && SeasonNumber match)
LINQ-->>SCM: Filtered records (duplicates per episode)
SCM->>LINQ: .GroupBy(r => r.DownloadId).Select(g => g.First())
LINQ-->>SCM: Deduplicated (1 record per unique download)
SCM->>LINQ: .Select(r => new { Title, Status, Protocol })
LINQ-->>SCM: grabbedItems (correct count)
SCM-->>SCM: Log and accumulate allGrabbedItems
Reviews (1): Last reviewed commit: "fixed duplicated grabbed items reported ..." | Re-trigger Greptile |
| .GroupBy(r => r.DownloadId) | ||
| .Select(g => g.First()) |
There was a problem hiding this comment.
No test coverage for deduplication logic
The SeekerCommandMonitor class has no corresponding test file (SeekerCommandMonitorTests.cs does not exist). Given this bug fix introduces a specific deduplication step, a regression test covering the season pack scenario — where multiple QueueRecords share the same DownloadId — would help guard against future regressions. The test could mock IArrClientFactory to return a queue with several records sharing a DownloadId and assert that InspectDownloadQueueAsync reports only one grabbed item.
No description provided.