From 9f10e9e7af6d6c8da555c85d86155b4b0df9dbe1 Mon Sep 17 00:00:00 2001
From: Kazgatari <56477241+Kazgatari@users.noreply.github.com>
Date: Fri, 31 Jul 2026 13:55:02 +0200
Subject: [PATCH] fixed resolver issues, where fuzzy search would not display
anything
---
webapp/src/app/app.routes.ts | 5 +-
.../search-results-state.service.ts | 22 ++++++-
.../uni-trend-parent.component.html | 2 +-
.../uni-trend-parent.component.ts | 60 ++++++++++++-------
.../src/app/resolvers/uni-trend.resolver.ts | 46 +++++++++++---
5 files changed, 102 insertions(+), 33 deletions(-)
diff --git a/webapp/src/app/app.routes.ts b/webapp/src/app/app.routes.ts
index 1a63d1a6..52eb03f3 100644
--- a/webapp/src/app/app.routes.ts
+++ b/webapp/src/app/app.routes.ts
@@ -285,6 +285,7 @@ export const routes: Routes = [
'search_type',
'topic',
'topics',
+ 'trend_topics',
'keyword',
'keywords',
'institutions',
@@ -294,7 +295,9 @@ export const routes: Routes = [
'fuzzy',
];
return keys.some(
- (key) => from.queryParamMap.get(key) !== to.queryParamMap.get(key),
+ (key) =>
+ from.queryParamMap.getAll(key).join(',') !==
+ to.queryParamMap.getAll(key).join(','),
);
},
},
diff --git a/webapp/src/app/modules/keywords-search/search-results/search-results-state.service.ts b/webapp/src/app/modules/keywords-search/search-results/search-results-state.service.ts
index 2401dc97..301b1d72 100644
--- a/webapp/src/app/modules/keywords-search/search-results/search-results-state.service.ts
+++ b/webapp/src/app/modules/keywords-search/search-results/search-results-state.service.ts
@@ -107,6 +107,15 @@ export class SearchResultsStateService {
result.push(entry);
}
+ console.log(
+ '[TrendDebug] SearchResultsStateService selectedKeywordEntries:',
+ result.map((e) => ({
+ kw: e.llm_keyword?.keyword,
+ topicName: e.topic_mapping?.topic?.display_name,
+ topicId: e.topic_mapping?.topic?.id,
+ })),
+ );
+
return result;
});
@@ -150,10 +159,21 @@ export class SearchResultsStateService {
return kw;
})
.filter((t) => t.length > 0);
- return Array.from(new Set(list));
+ const uniqueTopics = Array.from(new Set(list));
+ console.log(
+ '[TrendDebug] SearchResultsStateService topicsList computed:',
+ uniqueTopics,
+ );
+ return uniqueTopics;
});
setPayload(payload: SearchResultsPayload): void {
+ console.log('[TrendDebug] SearchResultsStateService setPayload:', {
+ keywords: payload.keywords,
+ extractedCount: payload.extractedKeywords?.length ?? 0,
+ manualCount: payload.manualKeywords?.length ?? 0,
+ fuzzy: payload.options?.fuzzy,
+ });
this._payload.set(payload);
}
}
diff --git a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.html b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.html
index 82362c53..1ea744c2 100644
--- a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.html
+++ b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.html
@@ -186,7 +186,7 @@
}
@if (selectedTrendTopics().length > 0) {
- @for (topic of selectedTrendTopics(); track topic) {
+ @for (topic of selectedTrendTopics(); track $index) {
@if (selectedSearchType() === 'news') {
0) {
this.selectedTrendTopics.set(resolved.topics);
const targetTopic =
@@ -855,12 +861,12 @@ export class UniTrendParentComponent implements OnInit {
effect(() => {
const kws = this.keywords();
const fuzzy = this.isFuzzy();
- const topics = fuzzy ? (this.state?.topicsList() ?? kws) : kws;
- const currentSelections = untracked(() => this.selectedTrendTopics());
- const currentActive = untracked(() => this.activeChartTopic());
+ const stateTopicsList = this.state?.topicsList();
+ const topics = fuzzy ? (stateTopicsList ?? kws) : kws;
if (topics.length > 0) {
- const altTopics = fuzzy ? kws : (this.state?.topicsList() ?? kws);
+ const currentSelections = untracked(() => this.selectedTrendTopics());
+ const altTopics = fuzzy ? kws : (stateTopicsList ?? kws);
const mappedSelections: string[] = [];
currentSelections.forEach((item) => {
@@ -874,29 +880,37 @@ export class UniTrendParentComponent implements OnInit {
}
});
- const finalSelections = Array.from(new Set(mappedSelections));
- if (finalSelections.length > 0) {
- this.selectedTrendTopics.set(finalSelections);
- } else {
- this.selectedTrendTopics.set(topics);
+ const targetSelections =
+ mappedSelections.length > 0
+ ? Array.from(new Set(mappedSelections))
+ : topics;
+
+ // Only update selectedTrendTopics if array actually changed to prevent DOM re-creation
+ const current = untracked(() => this.selectedTrendTopics());
+ const hasChanged =
+ targetSelections.length !== current.length ||
+ targetSelections.some((t, i) => t !== current[i]);
+
+ if (hasChanged) {
+ this.selectedTrendTopics.set(targetSelections);
}
- const active = currentActive;
- const updatedSelections = untracked(() => this.selectedTrendTopics());
- const mappedActive = this.getMappedTopic(active);
- if (
- mappedActive &&
- updatedSelections.includes(mappedActive) &&
- !this.isTopicEmpty(mappedActive)
- ) {
- this.activeChartTopic.set(mappedActive);
- } else {
- this.activeChartTopic.set(
- this.findFirstNonEmptyTopic(updatedSelections),
- );
+ const currentActive = untracked(() => this.activeChartTopic());
+ const validSelections = untracked(() => this.selectedTrendTopics());
+
+ if (!currentActive || !validSelections.includes(currentActive)) {
+ const firstValid = this.findFirstNonEmptyTopic(validSelections);
+ if (firstValid) {
+ this.activeChartTopic.set(firstValid);
+ } else if (validSelections.length > 0) {
+ this.activeChartTopic.set(validSelections[0]);
+ }
}
} else {
- this.selectedTrendTopics.set([]);
+ const current = untracked(() => this.selectedTrendTopics());
+ if (current.length > 0) {
+ this.selectedTrendTopics.set([]);
+ }
}
});
diff --git a/webapp/src/app/resolvers/uni-trend.resolver.ts b/webapp/src/app/resolvers/uni-trend.resolver.ts
index a5d2ddb9..82e87e07 100644
--- a/webapp/src/app/resolvers/uni-trend.resolver.ts
+++ b/webapp/src/app/resolvers/uni-trend.resolver.ts
@@ -66,18 +66,44 @@ export const uniTrendResolver: ResolveFn = (
keywords = searchState.keywords();
}
- let topics = params.getAll('topic');
+ let topics = [
+ ...params.getAll('trend_topics'),
+ ...params.getAll('trend_topic'),
+ ];
if (topics.length === 0) {
- const rawTopics = params.get('topics');
- if (rawTopics) {
- topics = rawTopics
- .split(',')
+ const rawTopicsList = [
+ ...params.getAll('topic'),
+ ...params.getAll('topics'),
+ ];
+ if (rawTopicsList.length > 0) {
+ topics = rawTopicsList
+ .flatMap((t) => t.split(','))
.map((t) => t.trim())
.filter((t) => t.length > 0);
}
}
- if (topics.length === 0 && searchState) {
- topics = fuzzy ? searchState.topicsList() : searchState.keywords();
+
+ console.log('[TrendDebug] Resolver input params:', {
+ fuzzy,
+ searchType,
+ urlTrendTopics: params.getAll('trend_topics'),
+ urlTopics: params.getAll('topics'),
+ urlKeywords: params.get('keywords') || params.getAll('keyword'),
+ hasSearchState: !!searchState,
+ });
+
+ if (searchState) {
+ const stateTopics = fuzzy
+ ? searchState.topicsList()
+ : searchState.keywords();
+ if (
+ topics.length === 0 ||
+ (fuzzy &&
+ stateTopics.length > 0 &&
+ topics.some((t) => t.startsWith('http') || /^T\d+$/i.test(t)))
+ ) {
+ topics = stateTopics;
+ }
}
// Fallback defaults if no topics/keywords present yet
@@ -90,6 +116,12 @@ export const uniTrendResolver: ResolveFn = (
keywords = topics;
}
+ console.log('[TrendDebug] Resolver resolved topics & keywords:', {
+ topics,
+ keywords,
+ searchType,
+ });
+
// Parse comparison items ensuring clean uppercase OpenAlex IDs
const instParams = params.getAll('institutions');
const parsedInstitutions: CompareItem[] = instParams.map((i) => {