feat: log warnings for conflicting custom formats#427
Closed
feat: log warnings for conflicting custom formats#427
Conversation
Add support for loading and checking conflicts.json from TRaSH Guides to warn users when they select mutually exclusive custom formats. - Add conflict types (TrashConflictEntry, TrashConflicts, TrashConflictsMapping) - Update TrashCache to include conflicts for both RADARR and SONARR - Add loadConflictsFromTrash function to load conflicts.json from TRaSH Guides - Add checkCustomFormatConflicts function to detect conflicts among selected CFs - Call conflict checking in pipeline after calculating CFs to manage Resolves GitHub issue for TRaSH Guides conflicts.json integration
Reviewer's GuideAdds TRaSH Guides conflicts.json support to cache and pipeline to detect and log warnings for mutually exclusive custom formats in Radarr/Sonarr configurations. Sequence diagram for checking custom format conflicts in the pipelinesequenceDiagram
actor User
participant CLI as CLI
participant pipeline as pipeline
participant calculateCFsToManage as calculateCFsToManage
participant checkCustomFormatConflicts as checkCustomFormatConflicts
participant TrashCache as TrashCache
participant logger as logger
User ->> CLI: run command
CLI ->> pipeline: pipeline(globalConfig, instanceConfig)
pipeline ->> calculateCFsToManage: calculateCFsToManage(config)
calculateCFsToManage -->> pipeline: idsToManage(Set<string>)
pipeline ->> checkCustomFormatConflicts: checkCustomFormatConflicts(arrType, idsToManage)
alt cache not ready
checkCustomFormatConflicts ->> logger: debug ((arrType) Cache not ready. Cannot check conflicts.)
checkCustomFormatConflicts -->> pipeline: return
else cache ready
checkCustomFormatConflicts ->> TrashCache: read cache[arrType].conflicts
alt no conflicts configured
checkCustomFormatConflicts ->> logger: debug ((arrType) No conflicts defined.)
checkCustomFormatConflicts -->> pipeline: return
else conflicts configured
alt fewer than 2 CFs selected
checkCustomFormatConflicts -->> pipeline: return
else potential conflicts
loop for each conflictGroup in conflicts
checkCustomFormatConflicts ->> TrashCache: iterate conflictGroup entries
alt more than one matching CF in group
checkCustomFormatConflicts ->> logger: warn ((arrType) Conflicting custom formats found: names)
end
end
alt no conflicts found
checkCustomFormatConflicts ->> logger: debug ((arrType) No conflicts detected among selected custom formats.)
end
end
end
end
pipeline -->> CLI: continue with loadCustomFormatDefinitions
Updated class diagram for TRaSH conflicts types and cacheclassDiagram
class TrashConflictEntry {
string name
string desc
}
class TrashConflicts {
Record~string, TrashConflictEntry~[] custom_formats
}
class TrashConflictsMapping {
Map~number, Record~string, TrashConflictEntry~~ mapping
}
class TrashQualityDefinition {
}
class TrashSonarrNaming {
}
class TrashRadarrNaming {
}
class TrashQP {
}
class TrashCF {
}
class TrashCFGroupMapping {
}
class TrashCacheSonarr {
Map~string, TrashQP~ qualityProfiles
Map~string, TrashCF~ customFormats
TrashCFGroupMapping customFormatGroups
Map~string, TrashQualityDefinition~ qualityDefinitions
TrashSonarrNaming naming
TrashConflictsMapping conflicts
}
class TrashCacheRadarr {
Map~string, TrashQP~ qualityProfiles
Map~string, TrashCF~ customFormats
TrashCFGroupMapping customFormatGroups
Map~string, TrashQualityDefinition~ qualityDefinitions
TrashRadarrNaming naming
TrashConflictsMapping conflicts
}
class TrashCache {
TrashCacheSonarr SONARR
TrashCacheRadarr RADARR
}
class TrashGuideService {
+loadConflictsFromTrash(arrType TrashArrSupported) TrashConflictsMapping
+checkCustomFormatConflicts(arrType TrashArrSupported, cfTrashIds Set~string~) void
}
TrashConflicts "1" o-- "*" TrashConflictEntry : contains
TrashConflictsMapping "1" o-- "*" TrashConflictEntry : grouped
TrashCache "1" o-- "1" TrashCacheSonarr : SONARR
TrashCache "1" o-- "1" TrashCacheRadarr : RADARR
TrashCacheSonarr "1" o-- "1" TrashConflictsMapping : conflicts
TrashCacheRadarr "1" o-- "1" TrashConflictsMapping : conflicts
TrashGuideService ..> TrashConflictsMapping : uses
TrashGuideService ..> TrashCache : reads
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
TrashConflictsMappingtype and the use ofMap<number, ...>keyed by array index add indirection without clear benefit; consider using thecustom_formatsarray directly (or a map keyed by a meaningful ID) to simplifyloadConflictsFromTrashand iteration incheckCustomFormatConflicts. - In
checkCustomFormatConflicts, you can return early whencfTrashIds.size < 2before checkingcacheReadyand accessingcache[arrType].conflictsto avoid unnecessary cache/logging work on the common trivial case.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `TrashConflictsMapping` type and the use of `Map<number, ...>` keyed by array index add indirection without clear benefit; consider using the `custom_formats` array directly (or a map keyed by a meaningful ID) to simplify `loadConflictsFromTrash` and iteration in `checkCustomFormatConflicts`.
- In `checkCustomFormatConflicts`, you can return early when `cfTrashIds.size < 2` before checking `cacheReady` and accessing `cache[arrType].conflicts` to avoid unnecessary cache/logging work on the common trivial case.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Add unit tests for loadConflictsFromTrash and checkCustomFormatConflicts functions to ensure conflict detection works correctly. - Test unsupported arr types return empty map - Test loading conflicts from conflicts.json - Test error handling when conflicts.json does not exist - Test handling of empty conflicts array - Test early return for unsupported arrType
Update loadConflictsFromTrash and checkCustomFormatConflicts to accept ArrType parameter to avoid type errors when called with non-RADARR/SONARR types. The functions already handle this case by returning early. This fixes TypeScript compilation errors when using any supported *arr type.
Member
Author
|
Supersedes by #428 |
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.
Add support for loading and checking conflicts.json from TRaSH Guides to warn users when they select mutually exclusive custom formats.
Resolves GitHub issue for TRaSH Guides conflicts.json integration
Summary by Sourcery
Integrate TRaSH Guides custom format conflict data into the cache and pipeline to warn when users select mutually exclusive custom formats.
New Features:
Enhancements: