Add group suggestions feature with API endpoints and frontend integration
ci / build-backend (push) Successful in 1m55s
ci / build-frontend (push) Successful in 44s
ci / tests (push) Successful in 2m8s
ci / sonar (push) Successful in 4m37s

Implemented new API endpoints for suggesting groups based on the current library, allowing admins to retrieve and create groups from suggestions. Updated the backend to include error handling for suggestions and added necessary DTOs. Enhanced the frontend with new API functions and UI components to display suggestions, improving the user experience for group management. Localization updates were made to support new features in both English and Russian.
This commit is contained in:
Leonid Pershin
2026-07-27 04:18:30 +03:00
parent 4774083dc9
commit 24fdbdf680
18 changed files with 810 additions and 1 deletions
+3
View File
@@ -39,6 +39,9 @@ export const qk = {
groups: {
all: ['admin', 'groups'] as const,
detail: (id: string) => ['admin', 'groups', id] as const,
suggestions: ['admin', 'groups', 'suggestions'] as const,
/** Подходящее по сохранённому правилу, но ещё не добавленное — проверяется при открытии группы. */
pending: (id: string) => ['admin', 'groups', id, 'pending'] as const,
},
collections: {
+14
View File
@@ -291,6 +291,20 @@ export type GroupCandidateDto = {
alreadyInGroup: boolean
}
/** Откуда взялось предложение группы — по нему подписывается происхождение. */
export type GroupSuggestionKind = 'Genre' | 'ShowKind' | 'Audience' | 'BigSeries'
/** Предложение завести группу: имя, объём и признак «уже создана». */
export type GroupSuggestionDto = {
key: string
kind: GroupSuggestionKind
name: string
showCount: number
unitCount: number
totalDurationSeconds: number
alreadyExists: boolean
}
export type MetadataCandidate = {
externalId: string
title: string
+15
View File
@@ -101,7 +101,22 @@ export const en = {
found: 'Found: {{total}}, new: {{fresh}}',
added: 'Items added: {{count}}',
alreadyIn: 'already in group',
pendingFound: 'New matches for this rule: {{count}} —',
pendingAdd: 'Add all ({{count}})',
elementKinds: { Show: 'Show', Collection: 'Collection' },
suggestions: {
title: 'Suggestions',
hint: 'Built from the current library. The button creates a group with these items and saves the rule — later additions are then one click away.',
stats: '{{shows}} shows · {{units}} units',
exists: 'already exists',
created: 'Group created',
kinds: {
Genre: 'genre',
ShowKind: 'kind',
Audience: 'rating',
BigSeries: 'big series',
},
},
filter: {
title: 'Selection rule',
hint: 'The rule only finds candidates — the group composition stays an explicit list.',
+15
View File
@@ -101,7 +101,22 @@ export const ru = {
found: 'Найдено: {{total}}, новых: {{fresh}}',
added: 'Добавлено позиций: {{count}}',
alreadyIn: 'уже в группе',
pendingFound: 'Под правило группы подходит нового: {{count}} —',
pendingAdd: 'Добавить все ({{count}})',
elementKinds: { Show: 'Шоу', Collection: 'Коллекция' },
suggestions: {
title: 'Предложения',
hint: 'Собрано по текущей библиотеке. Кнопка создаёт группу с этим составом и сохраняет правило набора — новое из библиотеки потом добавится в один клик.',
stats: '{{shows}} шоу · {{units}} ед.',
exists: 'уже есть',
created: 'Группа создана',
kinds: {
Genre: 'жанр',
ShowKind: 'тип',
Audience: 'рейтинг',
BigSeries: 'крупный сериал',
},
},
filter: {
title: 'Правило набора',
hint: 'Правило только ищет кандидатов — состав группы остаётся явным списком.',