moved fetching logic to resolvers

This commit is contained in:
2026-07-20 23:26:48 +02:00
parent 5b3176dc6e
commit fbe2f787a7
9 changed files with 266 additions and 338 deletions
+29 -2
View File
@@ -8,7 +8,10 @@ import { personResolver } from './resolvers/person.resolver';
import { personNewsResolver } from './resolvers/person-news.resolver';
import { institutionResolver } from './resolvers/institution.resolver';
import { bundProjectPageResolver } from './resolvers/bund-project-page.resolver';
import { dfgProjectsResolver } from './resolvers/dfg-projects.resolver';
import {
dfgProjectsResolver,
RESOLVING_PROJECT_PAGE_FOR,
} from './resolvers/dfg-projects.resolver';
import { institutionsResolver } from './resolvers/institutions.resolver';
import { bundProjectsFundingResolver } from './resolvers/bund-projects-funding.resolver';
import { dfgSingleProjectResolver } from './resolvers/dfg-single-project-resolver';
@@ -167,7 +170,23 @@ export const routes: Routes = [
children: [
{ path: '', pathMatch: 'full', redirectTo: 'persons' },
{ path: 'persons', component: KeywordsToPersonsResultsComponent },
{ path: 'projects', component: KeywordsToProjectsResultsComponent },
{
path: 'projects',
component: KeywordsToProjectsResultsComponent,
runGuardsAndResolvers: 'always',
resolve: {
dfgProjectPage: dfgProjectsResolver,
personCordisEuProjectPage: personCordisEuProjectPageResolver,
selectedDfgInstitutionsPage: selectedDfgInstitutionsResolver,
selectedDfgAuthorsPage: selectedDfgAuthorsResolver,
selectedTopicsPage: selectedTopicsResolver,
selectedEuInstitutionsPage: selectedInstitutionsResolver,
selectedEuAuthorsPage: selectedAuthorsResolver,
},
data: {
resolvingFor: RESOLVING_PROJECT_PAGE_FOR.KEYWORDS_SEARCH,
},
},
{ path: 'patents', component: KeywordsToPatentsResultsComponent },
{
path: 'works',
@@ -177,6 +196,10 @@ export const routes: Routes = [
selectedTopicsPage: selectedTopicsResolver,
selectedAuthorsPage: selectedAuthorsResolver,
selectedInstitutionsPage: selectedInstitutionsResolver,
workPage: workPageResolver,
},
data: {
resolvingFor: RESOLVING_WORK_PAGE_FOR.KEYWORDS_SEARCH,
},
},
{ path: 'news', component: KeywordsToNewsResultsComponent },
@@ -384,10 +407,14 @@ export const routes: Routes = [
personCordisEuProjectPage: personCordisEuProjectPageResolver,
selectedDfgInstitutionsPage: selectedDfgInstitutionsResolver,
selectedDfgAuthorsPage: selectedDfgAuthorsResolver,
selectedTopicsPage: selectedTopicsResolver,
selectedEuInstitutionsPage: selectedInstitutionsResolver,
selectedEuAuthorsPage: selectedAuthorsResolver,
},
runGuardsAndResolvers: 'always',
data: {
resolvingFor: RESOLVING_PROJECT_PAGE_FOR.PERSON,
},
},
{
path: 'publications',
@@ -1,31 +1,36 @@
<div class="result-layout">
<mat-card class="results-card">
<mat-card-content class="results-placeholder">
<mat-icon>groups</mat-icon>
<h2>Projectsliste</h2>
<p>
Die aktuelle Gewichtung ist unter <code>normalized</code> verfügbar.
</p>
</mat-card-content>
</mat-card>
<mat-card class="weights-card">
<div class="person-projects">
<div class="description-container">
<h5 style="font-weight: bold">Projekte</h5>
<p>Übersicht der durchgeführten Projekte.</p>
</div>
<mat-card appearance="outlined">
<mat-card-content>
<app-weights-sliders
[options]="weightOptions"
[initialWeights]="defaultWeights"
title="Projects-Gewichtung"
description="Werte zwischen 0 und 1. Summe wird normalisiert zu 1."
resetLabel="Ausgewogen"
applyLabel="Neu gewichten"
normalizedTitle="Normalisiert"
queryParamPrefix="projectW_"
[persistInQueryParams]="true"
[showApplyButton]="true"
[showResetButton]="true"
[showNormalizedPreview]="true"
(weightsChange)="onWeightsChange($event)"
(applyWeights)="onApplyWeights($event)" />
<mat-tab-group
[selectedIndex]="selectedTabIndex()"
(selectedIndexChange)="onTabChange($event)">
<mat-tab label="DFG">
<app-project-filters
[selectedInstitutionsPage]="selectedDfgInstitutionsPage()"
[selectedAuthorsPage]="selectedDfgAuthorsPage()"
[selectedTopicsPage]="selectedTopicsPage()"
[showFundingStartFilter]="true"
[showTopicFilter]="fuzzySearch()"
[showFundingEndFilter]="true"
[showAuthorFilter]="true"
[showInstitutionFilter]="true" />
<app-dfg-project-table
[page]="dfgProjectPage()"
[authorFilterEnabled]="true"
[topicFilterEnabled]="fuzzySearch()"
[institutionFilterEnabled]="true" />
</mat-tab>
<mat-tab label="EU">
<!-- <app-project-filters
[selectedInstitutionsPage]="selectedEuInstitutionsPage()"
[selectedAuthorsPage]="selectedEuAuthorsPage()" /> -->
<app-eu-project-table [page]="personCordisEuProjectPage()" />
</mat-tab>
</mat-tab-group>
</mat-card-content>
</mat-card>
</div>
@@ -1,29 +1,13 @@
/* ============================================================
RESULT LAYOUT
============================================================ */
.result-layout {
display: grid;
grid-template-columns: minmax(300px, 420px) 1fr;
grid-template-areas: 'summary results';
gap: 0.75rem;
align-items: start;
.person-projects {
padding: 2rem;
}
.search-summary-card {
grid-area: summary;
.description-container {
display: flex;
flex-direction: column;
}
.results-card {
grid-area: results;
}
.search-summary-card,
.results-card {
background: var(--sg-surface, #ffffff);
border: 1px solid var(--sg-divider, rgba(0, 0, 0, 0.12));
box-shadow: none;
.mat-mdc-card-content {
padding: 0.75rem;
}
mat-card,
mat-paginator {
background-color: var(--sg-background);
}
@@ -1,111 +1,73 @@
import { Component, inject, signal } from '@angular/core';
import { MatCardModule } from '@angular/material/card';
import { MatIconModule } from '@angular/material/icon';
import { Component, computed, input, signal } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { toSignal } from '@angular/core/rxjs-interop';
import { DfgInstitutionSummaryPage } from '../../../../api/model/dfgInstitutionSummaryPage';
import {
WeightMap,
WeightSliderOption,
WeightsSlidersComponent,
WeightsSlidersValue,
} from '../../../../shared/ui/weights-sliders/weights-sliders.component';
CordisEuProjectPage,
DfgProjectPage,
AuthorPage,
InstitutionPageV2,
DfgPersonSummaryPage,
TopicPageV2,
} from '../../../../api';
import { MatCardModule } from '@angular/material/card';
import { MatTabsModule } from '@angular/material/tabs';
import { ProjectFilterComponent } from '../../../../shared/ui/project-filters/project-filters.component';
import { DfgProjectTableComponent } from '../../../../shared/ui/dfg-project-table/dfg-project-table.component';
import { EuProjectTableComponent } from '../../../../shared/ui/eu-project-table/eu-project-table.component';
import { projectQueryParamKeys } from '../../../../resolvers/dfg-projects.resolver';
import { euProjectQueryParamKeys } from '../../../../resolvers/person-cordis-eu-project-page.resolver';
const PROJECT_TAB_QUERY_PARAM_KEY = 'project_type';
import { SearchResultsStateService } from '../search-results-state.service';
@Component({
selector: 'app-projects-results',
imports: [MatCardModule, MatIconModule, WeightsSlidersComponent],
imports: [
MatCardModule,
MatTabsModule,
ProjectFilterComponent,
DfgProjectTableComponent,
EuProjectTableComponent,
],
templateUrl: './projects-results.component.html',
styleUrl: './projects-results.component.scss',
})
export class KeywordsToProjectsResultsComponent {
// injects the state set by the parent route — no duplicate parsing here
private readonly state = inject(SearchResultsStateService);
dfgProjectPage = input.required<DfgProjectPage>();
personCordisEuProjectPage = input.required<CordisEuProjectPage>();
readonly defaultWeights: WeightMap = {
param1: 0.33,
param2: 0.33,
param3: 0.34,
};
selectedDfgInstitutionsPage = input.required<DfgInstitutionSummaryPage>();
selectedDfgAuthorsPage = input.required<DfgPersonSummaryPage>();
selectedTopicsPage = input.required<TopicPageV2>();
readonly weightOptions: WeightSliderOption[] = [
{
key: 'param1',
label: 'Parameter 1',
icon: 'workspace_premium',
description: 'Gewichtet Parameter 1.',
defaultValue: 0.5,
queryParamName: 'wParam1',
},
{
key: 'param2',
label: 'Parameter 2',
icon: 'workspace_premium',
description: 'Gewichtet Parameter 2.',
defaultValue: 0.5,
queryParamName: 'wParam2',
},
{
key: 'param3',
label: 'Parameter 3',
icon: 'workspace_premium',
description: 'Gewichtet Parameter 3.',
defaultValue: 0.5,
queryParamName: 'wParam3',
},
];
selectedEuInstitutionsPage = input.required<InstitutionPageV2>();
selectedEuAuthorsPage = input.required<AuthorPage>();
readonly currentWeights = signal<WeightsSlidersValue>({
raw: this.defaultWeights,
normalized: {
param1: 0.33,
param2: 0.33,
param3: 0.34,
},
rawSum: 2.5,
normalizedSum: 1,
valid: true,
readonly dfgQueryParamKeys = projectQueryParamKeys;
readonly euQueryParamKeys = euProjectQueryParamKeys;
constructor(
private readonly router: Router,
private readonly activatedRoute: ActivatedRoute,
) {}
loading = signal<boolean>(false);
queryParamMap = toSignal(this.activatedRoute.queryParamMap, {
initialValue: this.activatedRoute.snapshot.queryParamMap,
});
readonly fuzzySearch = computed(
() => this.queryParamMap().get('fuzzy') === 'true',
);
selectedTabIndex = computed(() => {
const type = this.queryParamMap().get(PROJECT_TAB_QUERY_PARAM_KEY);
return type === 'eu' ? 1 : 0;
});
readonly projects = signal<unknown[]>([]); // placeholder until the results service lands
private hasLoadedInitial = false;
onWeightsChange(value: WeightsSlidersValue): void {
this.currentWeights.set(value);
// fires once with the query-param-aware initial state — use it to load
if (!this.hasLoadedInitial) {
this.hasLoadedInitial = true;
this.loadprojects();
}
}
onApplyWeights(value: WeightsSlidersValue): void {
this.currentWeights.set(value);
this.loadprojects();
}
private loadprojects(): void {
const weights = this.currentWeights();
const requestPayload = {
manualKeywords: this.state.manualKeywords(),
extractedKeywords: this.state.extractedKeywords(),
keywords: this.state.keywords(),
fuzzy: this.state.fuzzySearch(),
weights: {
raw: weights.raw,
normalized: weights.normalized,
},
};
console.log(requestPayload);
/**
* TODO:
* this.projectsService.searchprojects(requestPayload).subscribe({
* next: results => this.projects.set(results),
* error: error => console.error(error),
* });
*/
onTabChange(index: number): void {
const type = index === 1 ? 'eu' : 'dfg';
this.router.navigate([], {
queryParams: { [PROJECT_TAB_QUERY_PARAM_KEY]: type },
queryParamsHandling: 'merge',
});
}
}
@@ -5,15 +5,11 @@
[selectedAuthorsPage]="selectedAuthorsPage()"
[showTopicFilter]="fuzzySearch()" />
@if (loading()) {
<app-loading [icon]="'article'" />
} @else {
<app-publication-table
[page]="works()"
[authorFilterEnabled]="true"
[institutionFilterEnabled]="true"
[topicFilterEnabled]="fuzzySearch()" />
}
<app-publication-table
[page]="workPage()"
[authorFilterEnabled]="true"
[institutionFilterEnabled]="true"
[topicFilterEnabled]="fuzzySearch()" />
<app-query-param-paginator
[total]="total()"
@@ -1,52 +1,25 @@
import {
Component,
DestroyRef,
OnInit,
inject,
signal,
computed,
input,
} from '@angular/core';
import { ActivatedRoute, ParamMap, Router } from '@angular/router';
import { takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
import { Component, OnInit, inject, computed, input } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { toSignal } from '@angular/core/rxjs-interop';
import { MatCardModule } from '@angular/material/card';
import { MatIconModule } from '@angular/material/icon';
import { MatButtonModule } from '@angular/material/button';
import { workQueryParamKeys } from '../../../../resolvers/work-page.resolver';
import { PublicationFilterComponent } from '../../../../shared/ui/publication-filters/publication-filters.component';
import { catchError, finalize, of, switchMap } from 'rxjs';
import { PublicationTableComponent } from '../../../../shared/ui/publication-table/publication-table.component';
import { LoadingComponent } from '../../../../shared/ui/loading/loading.component';
import { WorkPageV2 } from '../../../../api/model/workPageV2';
import { PaginationService } from '../../../../shared/services/pagination.service';
import { QueryParamPaginatorComponent } from '../../../../shared/ui/query-param-paginator/query-param-paginator.component';
import {
Author,
AuthorPage,
Institution,
InstitutionPageV2,
Topic,
TopicPageV2,
WorkTopic,
} from '../../../../api';
import { SortDirection, WorkSortBy, WorksV2Service } from '../../../../api';
import { AuthorPage, InstitutionPageV2, TopicPageV2 } from '../../../../api';
import { SearchResultsStateService } from '../search-results-state.service';
const EMPTY_WORK_PAGE: WorkPageV2 = {
elements: [],
total: 0,
page: 0,
size: 10,
};
@Component({
selector: 'app-works-results',
imports: [
MatCardModule,
MatIconModule,
MatButtonModule,
LoadingComponent,
PublicationTableComponent,
PublicationFilterComponent,
QueryParamPaginatorComponent,
@@ -58,19 +31,11 @@ export class KeywordsToWorksResultsComponent implements OnInit {
private readonly state = inject(SearchResultsStateService);
private readonly route = inject(ActivatedRoute);
private readonly router = inject(Router);
private readonly worksService = inject(WorksV2Service);
private readonly destroyRef = inject(DestroyRef);
public readonly paginationService = inject(PaginationService);
loading = signal<boolean>(false);
private readonly yearParamKey = workQueryParamKeys.years;
private readonly typeParamKey = workQueryParamKeys.types;
private readonly languageParamKey = workQueryParamKeys.language;
private readonly institutionParamKey = workQueryParamKeys.institutionId;
private readonly authorParamKey = workQueryParamKeys.authorId;
private readonly topicParamKey = workQueryParamKeys.topicId;
private readonly pageParamKey = workQueryParamKeys.page;
queryParamMap = toSignal(this.route.queryParamMap, {
initialValue: this.route.snapshot.queryParamMap,
@@ -87,122 +52,20 @@ export class KeywordsToWorksResultsComponent implements OnInit {
this.queryParamMap().getAll(this.topicParamKey),
);
total = computed(() => this.works()?.total ?? 0);
totalElements = computed(() => this.works()?.total ?? 0);
elements = computed(() => this.works()?.elements ?? []);
fuzzySearch = computed(() => this.queryParamMap().get('fuzzy') === 'true');
readonly works = toSignal(
this.route.queryParamMap.pipe(
switchMap((params) => this.fetchWorks(params)),
takeUntilDestroyed(this.destroyRef),
),
{ initialValue: EMPTY_WORK_PAGE },
);
private readonly institutionsFromWorks = computed(() => {
const map = new Map<string, Institution>();
for (const work of this.works().elements ?? []) {
for (const authorship of work.authorships ?? []) {
for (const institution of authorship.institutions ?? []) {
if (institution.id) map.set(institution.id, institution);
}
}
}
return map;
});
private readonly authorsFromWorks = computed(() => {
const map = new Map<string, Author>();
for (const work of this.works().elements ?? []) {
for (const authorship of work.authorships ?? []) {
const author = authorship.author;
if (author?.id) map.set(author.id, author);
}
}
return map;
});
private readonly topicsFromWorks = computed(() => {
const map = new Map<string, WorkTopic>();
for (const work of this.works().elements ?? []) {
for (const topic of work.topics ?? []) {
if (topic.id) map.set(topic.id, topic);
}
}
return map;
});
selectedAuthors = computed<Author[]>(() => {
const byId = this.authorsFromWorks();
return this.selectedAuthorIdsQueryParams()
.map((id) => byId.get(id))
.filter((author): author is Author => !!author);
});
workPage = input.required<WorkPageV2>();
selectedInstitutionsPage = input.required<InstitutionPageV2>();
selectedTopicsPage = input.required<TopicPageV2>();
selectedAuthorsPage = input.required<AuthorPage>();
total = computed(() => this.workPage().total ?? 0);
totalElements = computed(() => this.workPage().total ?? 0);
elements = computed(() => this.workPage().elements ?? []);
fuzzySearch = computed(() => this.queryParamMap().get('fuzzy') === 'true');
ngOnInit(): void {}
private fetchWorks(params: ParamMap) {
this.loading.set(true);
// Base search topics — derived from the keyword→topic mapping.
// This remains the actual search criterion.
const baseTopicIds = this.state
.selectedKeywordEntries()
.map((entry) => entry.topic_mapping?.topic?.id)
.filter((id): id is string => !!id);
const keywords = this.state.keywords();
if (baseTopicIds.length === 0 && keywords.length === 0) {
this.loading.set(false);
return of(EMPTY_WORK_PAGE);
}
const title = params.get('title') ?? undefined;
const filterTopicIds = params.getAll(this.topicParamKey);
const page = Number(params.get(this.pageParamKey)) || 0;
const size = Number(params.get('size')) || 10;
const publicationYears = params
.getAll(this.yearParamKey)
.map(Number)
.filter((year) => !Number.isNaN(year));
const publicationTypes = params.getAll(this.typeParamKey);
const publicationLanguages = params.getAll(this.languageParamKey);
const institutionIds = params.getAll(this.institutionParamKey);
const authorIds = params.getAll(this.authorParamKey);
const fuzzy = params.get('fuzzy') === 'true';
const sortBy = (params.get('sort_by') ?? 'publication_year') as WorkSortBy;
const sortDirection = (params.get('sort_direction') ??
'desc') as SortDirection;
return this.worksService
.getWorksByKeywords(
[],
baseTopicIds,
filterTopicIds,
keywords,
fuzzy,
publicationYears,
publicationTypes,
institutionIds,
authorIds,
publicationLanguages,
title,
page,
size,
sortBy,
sortDirection,
)
.pipe(
catchError((err) => {
console.error(err);
return of(EMPTY_WORK_PAGE);
}),
finalize(() => this.loading.set(false)),
);
}
clearFilters(): void {
this.router.navigate([], {
queryParams: {
@@ -7,17 +7,33 @@ export const projectQueryParamKeys = {
size: 'size',
title: 'title',
institutionId: 'institutionId',
years: 'years',
funding_start: 'funding_start',
funding_end: 'funding_end',
authorId: 'authorId',
topicId: 'topicId',
sortBy: 'sort_by',
sortDirection: 'sort_direction',
} as const;
const RESOLVING_PROJECT_PAGE_FOR_KEY = 'resolvingFor';
export const RESOLVING_PROJECT_PAGE_FOR = {
PERSON: 'PERSON',
KEYWORDS_SEARCH: 'KEYWORDS_SEARCH',
} as const;
export const dfgProjectsResolver: ResolveFn<DfgProjectPage> = (
route,
state,
) => {
const resolvingFor: (typeof RESOLVING_PROJECT_PAGE_FOR)[keyof typeof RESOLVING_PROJECT_PAGE_FOR] =
route.data[RESOLVING_PROJECT_PAGE_FOR_KEY] ||
RESOLVING_PROJECT_PAGE_FOR.PERSON;
console.log(
'Resolving project page for',
resolvingFor,
'with route data:',
route.data,
);
const rawAuthorId = route.parent?.params['id'];
const page = Number(route.queryParamMap.get(projectQueryParamKeys.page)) || 0;
@@ -30,11 +46,15 @@ export const dfgProjectsResolver: ResolveFn<DfgProjectPage> = (
const sortDirection =
route.queryParamMap.get(projectQueryParamKeys.sortDirection) || 'asc';
// TODO: verify ProjectsService.getDfgProjects accepts institution/author
// filters. Wire these in once the service signature supports them.
const topics = route.queryParamMap.getAll(projectQueryParamKeys.topicId);
const years = route.queryParamMap.getAll(projectQueryParamKeys.years);
const fundingStart = route.queryParamMap.getAll(
projectQueryParamKeys.funding_start,
);
const fundingEnd = route.queryParamMap.getAll(
projectQueryParamKeys.funding_end,
);
const filteredTopicIds = route.queryParamMap.getAll(
projectQueryParamKeys.topicId,
);
const institutionIds = route.queryParamMap
.getAll(projectQueryParamKeys.institutionId)
.map((id) => Number(id))
@@ -43,24 +63,44 @@ export const dfgProjectsResolver: ResolveFn<DfgProjectPage> = (
.getAll(projectQueryParamKeys.authorId)
.map((id) => Number(id))
.filter((id) => !isNaN(id));
console.log(
'RESOLVING',
authorIds,
institutionIds,
topics,
years,
searchTerm,
);
return inject(ProjectsService).getDfgProjects(
rawAuthorId,
authorIds,
institutionIds,
searchTerm,
topics,
years,
page,
size,
sortBy,
sortDirection,
);
if (resolvingFor === RESOLVING_PROJECT_PAGE_FOR.PERSON) {
return inject(ProjectsService).getDfgProjects(
rawAuthorId,
authorIds,
institutionIds,
searchTerm,
[],
[],
filteredTopicIds,
fundingStart,
fundingEnd,
page,
size,
sortBy,
sortDirection,
false,
);
} else if (resolvingFor === RESOLVING_PROJECT_PAGE_FOR.KEYWORDS_SEARCH) {
const keywords = route.queryParamMap.get('keywords')?.split(',') ?? [];
const selectedTopicIds = route.queryParamMap.getAll('topics');
const fuzzySearch = route.queryParamMap.get('fuzzy') === 'true';
return inject(ProjectsService).getDfgProjects(
undefined,
authorIds,
institutionIds,
searchTerm,
keywords,
selectedTopicIds,
filteredTopicIds,
fundingStart,
fundingEnd,
page,
size,
sortBy,
sortDirection,
fuzzySearch,
);
} else {
throw new Error(`Unknown resolvingFor value: ${resolvingFor}`);
}
};
@@ -15,10 +15,10 @@ export const euProjectQueryParamKeys = {
export const personCordisEuProjectPageResolver: ResolveFn<
CordisEuProjectPage
> = (route, state) => {
const rawAuthorId = route.parent?.paramMap.get('id') ?? null;
if (!rawAuthorId) {
throw new Error('Author ID is required to resolve EU projects.');
}
const rawAuthorId = route.parent?.params['id'];
// if (!rawAuthorId) {
// throw new Error('Author ID is required to resolve EU projects.');
// }
const page =
Number(route.queryParamMap.get(euProjectQueryParamKeys.page)) || 0;
@@ -38,7 +38,7 @@ export const personCordisEuProjectPageResolver: ResolveFn<
euProjectQueryParamKeys.authorId,
);
return inject(ProjectsService).getEuProjectsForAuthor(
rawAuthorId,
rawAuthorId || '1',
// searchTerm,
// page,
// size,
@@ -8,6 +8,7 @@ import {
SortDirection,
WorkSortBy,
WorksV2Service,
WorksService,
} from '../api';
import { inject } from '@angular/core';
@@ -15,6 +16,7 @@ const RESOLVING_WORK_PAGE_FOR_KEY = 'resolvingFor';
export const RESOLVING_WORK_PAGE_FOR = {
PERSON: 'PERSON',
INSTITUTION: 'INSTITUTION',
KEYWORDS_SEARCH: 'KEYWORDS_SEARCH',
} as const;
export const workQueryParamKeys = {
@@ -106,6 +108,55 @@ export const workPageResolver: ResolveFn<WorkPageV2> = (
sortBy,
sortDirection,
);
} else if (resolvingFor === RESOLVING_WORK_PAGE_FOR.KEYWORDS_SEARCH) {
const baseTopicIds = route.queryParamMap.get('topics')?.split(',') ?? [];
const keywords = route.queryParamMap.get('keywords')?.split(',') ?? [];
const title =
route.queryParamMap.get(workQueryParamKeys.title) ?? undefined;
const filterTopicIds = route.queryParamMap.getAll(
workQueryParamKeys.topicId,
);
const page = Number(route.queryParamMap.get(workQueryParamKeys.page)) || 0;
const size = Number(route.queryParamMap.get(workQueryParamKeys.size)) || 10;
const publicationYears = route.queryParamMap
.getAll(workQueryParamKeys.years)
.map(Number)
.filter((year) => !Number.isNaN(year));
const publicationTypes = route.queryParamMap.getAll(
workQueryParamKeys.types,
);
const publicationLanguages = route.queryParamMap.getAll(
workQueryParamKeys.language,
);
const institutionIds = route.queryParamMap.getAll(
workQueryParamKeys.institutionId,
);
const authorIds = route.queryParamMap.getAll(workQueryParamKeys.authorId);
const fuzzy = route.queryParamMap.get('fuzzy') === 'true';
const sortBy = (route.queryParamMap.get(workQueryParamKeys.sortBy) ??
'publication_year') as WorkSortBy;
const sortDirection = (route.queryParamMap.get(
workQueryParamKeys.sortDirection,
) ?? 'desc') as SortDirection;
return inject(WorksV2Service).getWorksByKeywords(
[],
baseTopicIds,
filterTopicIds,
keywords,
fuzzy,
publicationYears,
publicationTypes,
institutionIds,
authorIds,
publicationLanguages,
title,
page,
size,
sortBy,
sortDirection,
);
} else {
throw new Error(`Unknown resolvingFor value: ${resolvingFor}`);
}