feat(news-keyword-search): add search bar
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/pr-dev Build started...

This commit is contained in:
2026-08-24 21:49:05 +02:00
parent 05eb4c49f7
commit 27433efe72
7 changed files with 92 additions and 36 deletions
+4
View File
@@ -154,6 +154,7 @@ async def search_news_by_keywords(
year_to: int | None = None,
relevance_values: list | None = None,
sort_order: str | None = None,
title: str | None = None,
) -> NewsPage:
"""Searches the news for the keywords of a keywords-search run.
@@ -189,6 +190,9 @@ async def search_news_by_keywords(
return _empty_page(page, page_size)
clauses = await _filter_clauses(year_from, year_to, relevance_values)
if title and title.strip():
clauses.append({"match_phrase_prefix": {"maintitle": title.strip()}})
query = {
"bool": {
"should": should,
+5
View File
@@ -147,6 +147,10 @@ async def search_news_by_keywords(
pattern="^(asc|desc)$",
),
] = None,
title: Annotated[
str | None,
Query(description="Narrows the results to articles whose title matches this text."),
] = None,
):
return await logic.search_news_by_keywords(
keywords=keywords or [],
@@ -159,6 +163,7 @@ async def search_news_by_keywords(
year_from=year_from,
year_to=year_to,
relevance_values=_parse_relevance(relevance),
title=title,
)
+20
View File
@@ -563,6 +563,7 @@ export class NewsService extends BaseService {
* @param yearFrom Earliest publication year (inclusive).
* @param yearTo Latest publication year (inclusive).
* @param sortOrder Overrides relevance ranking with a date sort: \'desc\' (newest first) or \'asc\' (oldest first).
* @param title Narrows the results to articles whose title matches this text.
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
@@ -577,6 +578,7 @@ export class NewsService extends BaseService {
yearFrom?: number,
yearTo?: number,
sortOrder?: string,
title?: string,
observe?: 'body',
reportProgress?: boolean,
options?: {
@@ -596,6 +598,7 @@ export class NewsService extends BaseService {
yearFrom?: number,
yearTo?: number,
sortOrder?: string,
title?: string,
observe?: 'response',
reportProgress?: boolean,
options?: {
@@ -615,6 +618,7 @@ export class NewsService extends BaseService {
yearFrom?: number,
yearTo?: number,
sortOrder?: string,
title?: string,
observe?: 'events',
reportProgress?: boolean,
options?: {
@@ -634,6 +638,7 @@ export class NewsService extends BaseService {
yearFrom?: number,
yearTo?: number,
sortOrder?: string,
title?: string,
observe: any = 'body',
reportProgress: boolean = false,
options?: {
@@ -705,6 +710,11 @@ export class NewsService extends BaseService {
<any>sortOrder,
'sortOrder',
);
localVarQueryParameters = this.addToHttpParams(
localVarQueryParameters,
<any>title,
'title',
);
let localVarHeaders = this.defaultHeaders;
@@ -769,6 +779,7 @@ export class NewsService extends BaseService {
* @param yearFrom Earliest publication year (inclusive).
* @param yearTo Latest publication year (inclusive).
* @param sortOrder Overrides relevance ranking with a date sort: \&#39;desc\&#39; (newest first) or \&#39;asc\&#39; (oldest first).
* @param title Narrows the results to articles whose title matches this text.
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
@@ -783,6 +794,7 @@ export class NewsService extends BaseService {
yearFrom?: number,
yearTo?: number,
sortOrder?: string,
title?: string,
observe?: 'body',
reportProgress?: boolean,
options?: {
@@ -802,6 +814,7 @@ export class NewsService extends BaseService {
yearFrom?: number,
yearTo?: number,
sortOrder?: string,
title?: string,
observe?: 'response',
reportProgress?: boolean,
options?: {
@@ -821,6 +834,7 @@ export class NewsService extends BaseService {
yearFrom?: number,
yearTo?: number,
sortOrder?: string,
title?: string,
observe?: 'events',
reportProgress?: boolean,
options?: {
@@ -840,6 +854,7 @@ export class NewsService extends BaseService {
yearFrom?: number,
yearTo?: number,
sortOrder?: string,
title?: string,
observe: any = 'body',
reportProgress: boolean = false,
options?: {
@@ -911,6 +926,11 @@ export class NewsService extends BaseService {
<any>sortOrder,
'sortOrder',
);
localVarQueryParameters = this.addToHttpParams(
localVarQueryParameters,
<any>title,
'title',
);
let localVarHeaders = this.defaultHeaders;
@@ -1,42 +1,51 @@
<div class="content">
<div class="filters">
<app-filter-card>
<app-query-param-selector
class="relevance-field"
[options]="relevanceOptions"
[queryParamKey]="keywordsNewsQueryParamKeys.relevance"
label="Relevanz"
[icon]="CHECK_CIRCLE_ICON"
[multiple]="true" />
<app-query-param-input
class="title-field"
[queryParamKey]="keywordsNewsQueryParamKeys.title"
[queryParamPageKey]="keywordsNewsQueryParamKeys.page"
label="Suchen nach Titel"
[debounceTime]="300" />
<app-query-param-selector
class="sort-order-field"
[options]="sortOrderOptions"
[queryParamKey]="keywordsNewsQueryParamKeys.sortOrder"
label="Sortierung"
[icon]="SORT_ICON" />
</app-filter-card>
<div class="filter-row">
<app-filter-card>
<app-query-param-selector
class="relevance-field"
[options]="relevanceOptions"
[queryParamKey]="keywordsNewsQueryParamKeys.relevance"
label="Relevanz"
[icon]="CHECK_CIRCLE_ICON"
[multiple]="true" />
<app-year-range-slider
[minYear]="minYear"
[maxYear]="maxYear"
[(startYear)]="yearFrom"
[(endYear)]="yearTo"
(startYearChange)="applyYearFilter()"
(endYearChange)="applyYearFilter()">
</app-year-range-slider>
<app-query-param-selector
class="sort-order-field"
[options]="sortOrderOptions"
[queryParamKey]="keywordsNewsQueryParamKeys.sortOrder"
label="Sortierung"
[icon]="SORT_ICON" />
</app-filter-card>
@if (hasActiveFilters()) {
<button
class="reset-filter-btn"
mat-stroked-button
type="button"
(click)="resetFilters()"
aria-label="Filter zurücksetzen">
<mat-icon>{{ FILTER_OFF_ICON }}</mat-icon>
<span>Zurücksetzen</span>
</button>
}
<app-year-range-slider
[minYear]="minYear"
[maxYear]="maxYear"
[(startYear)]="yearFrom"
[(endYear)]="yearTo"
(startYearChange)="applyYearFilter()"
(endYearChange)="applyYearFilter()">
</app-year-range-slider>
@if (hasActiveFilters()) {
<button
class="reset-filter-btn"
mat-stroked-button
type="button"
(click)="resetFilters()"
aria-label="Filter zurücksetzen">
<mat-icon>{{ FILTER_OFF_ICON }}</mat-icon>
<span>Zurücksetzen</span>
</button>
}
</div>
</div>
<ng-template #titleTmp let-article>
@@ -9,10 +9,20 @@
============================================================ */
.filters {
display: flex;
flex-wrap: wrap;
align-items: stretch;
flex-direction: column;
gap: 0.75rem;
.title-field {
width: 100%;
}
.filter-row {
display: flex;
flex-wrap: wrap;
align-items: stretch;
gap: 0.75rem;
}
.relevance-field,
.sort-order-field {
min-width: 200px;
@@ -21,6 +21,7 @@ import {
GenericColumn,
} from '../../../../shared/ui/data-table/data-table.component';
import { QueryParamPaginatorComponent } from '../../../../shared/ui/query-param-paginator/query-param-paginator.component';
import { QueryParamInputComponent } from '../../../../shared/ui/query-param-input/query-param-input.component';
import { AppTopicChipComponent } from '../../../../shared/ui/app-topic-chip/app-topic-chip.component';
import { ChipOverflowToggleComponent } from '../../../../shared/ui/chip-overflow-toggle/chip-overflow-toggle.component';
import { FilterCardComponent } from '../../../../shared/ui/filter-card/filter-card.component';
@@ -66,6 +67,7 @@ type NewsResult = NewsPage['results'][number];
ChipOverflowToggleComponent,
FilterCardComponent,
QueryParamPaginatorComponent,
QueryParamInputComponent,
QueryParamSelectorComponent,
YearRangeSliderComponent,
],
@@ -138,6 +140,7 @@ export class KeywordsToNewsResultsComponent {
!!params.get(keywordsNewsQueryParamKeys.yearFrom) ||
!!params.get(keywordsNewsQueryParamKeys.yearTo) ||
!!params.get(keywordsNewsQueryParamKeys.sortOrder) ||
!!params.get(keywordsNewsQueryParamKeys.title) ||
this.selectedTopicIds().length > 0
);
});
@@ -148,6 +151,7 @@ export class KeywordsToNewsResultsComponent {
!!params.get(keywordsNewsQueryParamKeys.relevance) ||
!!params.get(keywordsNewsQueryParamKeys.yearFrom) ||
!!params.get(keywordsNewsQueryParamKeys.yearTo) ||
!!params.get(keywordsNewsQueryParamKeys.title) ||
this.selectedTopicIds().length > 0
);
});
@@ -330,6 +334,7 @@ export class KeywordsToNewsResultsComponent {
[keywordsNewsQueryParamKeys.yearTo]: null,
[keywordsNewsQueryParamKeys.topicId]: null,
[keywordsNewsQueryParamKeys.sortOrder]: null,
[keywordsNewsQueryParamKeys.title]: null,
[keywordsNewsQueryParamKeys.page]: 0,
},
queryParamsHandling: 'merge',
@@ -12,6 +12,7 @@ export const keywordsNewsQueryParamKeys = {
yearTo: 'yearTo',
topicId: 'topicId',
sortOrder: 'sorting_order',
title: 'title',
} as const;
const emptyPage = (page: number, pageSize: number): NewsPage => ({
@@ -47,6 +48,7 @@ export const keywordsNewsPageResolver: ResolveFn<NewsPage> = (route) => {
const sortOrder = parseSortOrder(
params.get(keywordsNewsQueryParamKeys.sortOrder),
);
const title = params.get(keywordsNewsQueryParamKeys.title) || undefined;
return inject(NewsService).getNewsByKeywords(
keywords,
@@ -59,6 +61,7 @@ export const keywordsNewsPageResolver: ResolveFn<NewsPage> = (route) => {
yearFrom,
yearTo,
sortOrder,
title,
);
};