Sort field mapping logic is duplicated between CollectionService.mapCollectionSortField() and SuggestionService.mapSortField(). This code duplication increases maintenance burden, risks inconsistent behavior between endpoints, and violates the DRY principle. Adding new sort fields requires changes in multiple places.
Extract sort logic to a shared SortFieldMapper utility class or create a @SortableField() decorator. Centralize sort field definitions with their database mappings. Ensure all services use the shared implementation. Add unit tests specifically for sort mapping logic to prevent regressions.
Sort field mapping logic is duplicated between
CollectionService.mapCollectionSortField()andSuggestionService.mapSortField(). This code duplication increases maintenance burden, risks inconsistent behavior between endpoints, and violates the DRY principle. Adding new sort fields requires changes in multiple places.Extract sort logic to a shared
SortFieldMapperutility class or create a@SortableField()decorator. Centralize sort field definitions with their database mappings. Ensure all services use the shared implementation. Add unit tests specifically for sort mapping logic to prevent regressions.