Refactor collection and group suggestion handling to improve name comparison logic
Updated the CreateCollectionFromSuggestionCommandHandler and CreateGroupFromSuggestionCommandHandler to compare names in memory rather than using SQL queries for case-insensitive checks. This change addresses potential discrepancies with SQL's case sensitivity, particularly with special characters. Additionally, modified unit tests to use array syntax for assertions, enhancing readability and consistency across the test suite.
This commit is contained in:
@@ -73,9 +73,11 @@ export function parseEpisodeName(name: string, opts?: ParseOptions): ParsedEpiso
|
||||
* Диапазон сезонов в имени: «Season.3-4», «S01-S03». Такая папка накрывает несколько сезонов, и
|
||||
* подставлять из неё один номер нельзя — честнее не угадывать вовсе.
|
||||
*/
|
||||
// Разделитель вокруг тире — без самого дефиса: иначе «-» подходит и под разделитель, и под тире,
|
||||
// и движок перебирает варианты впустую (у Sonar это «super-linear backtracking»).
|
||||
const SEASON_RANGES = [
|
||||
/(?:s|season|сезон[ы]?)[\s._-]*\d{1,2}[\s._-]*[-–][\s._-]*(?:s|season)?\d{1,2}/i,
|
||||
/\d{1,2}[\s._-]*[-–][\s._-]*\d{1,2}[\s._-]*сезон/i,
|
||||
/(?:s|season|сезоны?)[\s._-]*\d{1,2}[\s._]*[-–][\s._]*(?:s|season)?\d{1,2}/i,
|
||||
/\d{1,2}[\s._]*[-–][\s._]*\d{1,2}[\s._-]*сезон/i,
|
||||
]
|
||||
|
||||
/** Сезон в имени одного сегмента пути: «S02», «Season 2», «Сезон 2», «2 сезон». */
|
||||
|
||||
@@ -74,6 +74,24 @@ export function ShowsPanel() {
|
||||
const invalidate = () => queryClient.invalidateQueries({ queryKey: qk.shows.all })
|
||||
const onError = useApiError()
|
||||
|
||||
// Отметки страницей и по одной. Вынесены из разметки: три вложенных стрелки прямо в onChange
|
||||
// читаются хуже, чем имя действия.
|
||||
const pageAllSelected =
|
||||
pageItems.length > 0 && pageItems.every((show) => selected.includes(show.id))
|
||||
|
||||
const togglePage = (checked: boolean) =>
|
||||
setSelected((current) => {
|
||||
const ids = pageItems.map((show) => show.id)
|
||||
return checked
|
||||
? [...new Set([...current, ...ids])]
|
||||
: current.filter((id) => !ids.includes(id))
|
||||
})
|
||||
|
||||
const toggleShow = (showId: string) =>
|
||||
setSelected((current) =>
|
||||
current.includes(showId) ? current.filter((id) => id !== showId) : [...current, showId],
|
||||
)
|
||||
|
||||
const createMutation = useMutation({
|
||||
mutationFn: () =>
|
||||
createShow({
|
||||
@@ -184,14 +202,8 @@ export function ShowsPanel() {
|
||||
<input
|
||||
type="checkbox"
|
||||
aria-label={t('admin.shows.bulk.selectPage')}
|
||||
checked={pageItems.length > 0 && pageItems.every((s) => selected.includes(s.id))}
|
||||
onChange={(e) =>
|
||||
setSelected((current) =>
|
||||
e.target.checked
|
||||
? [...new Set([...current, ...pageItems.map((s) => s.id)])]
|
||||
: current.filter((id) => !pageItems.some((s) => s.id === id)),
|
||||
)
|
||||
}
|
||||
checked={pageAllSelected}
|
||||
onChange={(e) => togglePage(e.target.checked)}
|
||||
/>
|
||||
</th>
|
||||
<SortHeader
|
||||
@@ -248,13 +260,7 @@ export function ShowsPanel() {
|
||||
type="checkbox"
|
||||
aria-label={show.name}
|
||||
checked={selected.includes(show.id)}
|
||||
onChange={() =>
|
||||
setSelected((current) =>
|
||||
current.includes(show.id)
|
||||
? current.filter((id) => id !== show.id)
|
||||
: [...current, show.id],
|
||||
)
|
||||
}
|
||||
onChange={() => toggleShow(show.id)}
|
||||
/>
|
||||
</td>
|
||||
<td className="px-4 py-2">
|
||||
|
||||
Reference in New Issue
Block a user