+ (click)="onSelectPrimaryBadge()"
+ [title]="'Klicken, um die Einrichtung zur Vergleichsliste hinzuzufügen'">
Zugewiesen:
{{
@@ -77,6 +72,15 @@
{{ inst.name }}
+
+ open_in_new
+
}
- @for (key of [entityId() || titleText() || 'overall']; track key) {
-
- }
+
diff --git a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts
index 309069db..0557dc8f 100644
--- a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts
+++ b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts
@@ -367,16 +367,25 @@ export class UniTrendParentComponent implements OnInit {
}
// Default: publications, patents, projects
+ // Resilient ID normalization helper
+ const cleanId = (id: string | null | undefined): string => {
+ if (!id) return '';
+ const lower = id.toLowerCase().trim();
+ return lower.includes('/') ? lower.split('/').pop()! : lower;
+ };
+
const currentInstIds = new Set(
- this.comparisonInstitutions().map((i: CompareItem) => i.id.toLowerCase()),
+ this.comparisonInstitutions().map((i: CompareItem) => cleanId(i.id)),
);
const currentCountryIds = new Set(
- this.comparisonCountries().map((c: CompareItem) => c.id.toLowerCase()),
+ this.comparisonCountries().map((c: CompareItem) => cleanId(c.id)),
);
const currentRegionIds = new Set(
- this.comparisonRegions().map((r: CompareItem) => r.id.toLowerCase()),
+ this.comparisonRegions().map((r: CompareItem) => cleanId(r.id)),
+ );
+ const primaryInstCleanId = cleanId(
+ this.primaryInstitution() || 'I62318514',
);
- const defaultInstId = 'https://openalex.org/I62318514'.toLowerCase();
const primaryInstSeries: TrendSeries[] = [];
const compInstSeries: TrendSeries[] = [];
@@ -384,19 +393,20 @@ export class UniTrendParentComponent implements OnInit {
const regionSeries: TrendSeries[] = [];
raw.series.forEach((s: TrendSeries) => {
- const id = s.entity_id.toLowerCase();
+ const cId = cleanId(s.entity_id);
if (s.entity_type === 'institution') {
- if (id === defaultInstId) {
+ if (cId === primaryInstCleanId) {
primaryInstSeries.push(s);
- } else if (currentInstIds.has(id)) {
+ }
+ if (currentInstIds.has(cId)) {
compInstSeries.push(s);
}
} else if (s.entity_type === 'country') {
- if (currentCountryIds.has(id)) {
+ if (currentCountryIds.has(cId)) {
countrySeries.push(s);
}
} else if (s.entity_type === 'region') {
- if (currentRegionIds.has(id)) {
+ if (currentRegionIds.has(cId)) {
regionSeries.push(s);
}
}
@@ -554,18 +564,23 @@ export class UniTrendParentComponent implements OnInit {
// Handle initialization and synchronization of URL state
this.route.queryParams.subscribe((params) => {
+ let hasInstsFromUrl = false;
if (params['search_type']) {
this.selectedSearchType.set(params['search_type'] as any);
}
// Parse institutions serialized as id|name
if (params['institutions']) {
+ hasInstsFromUrl = true;
const insts = Array.isArray(params['institutions'])
? params['institutions']
: [params['institutions']];
const parsed = insts.map((i: string) => {
const parts = i.split('|');
- return { id: parts[0], name: parts[1] || parts[0] };
+ const cleanId = parts[0].includes('/')
+ ? parts[0].split('/').pop() || parts[0]
+ : parts[0];
+ return { id: cleanId, name: parts[1] || parts[0] };
});
const currentIds = this.comparisonInstitutions()
@@ -579,10 +594,11 @@ export class UniTrendParentComponent implements OnInit {
if (currentIds !== parsedIds) {
this.comparisonInstitutions.set(parsed);
}
- } else {
- if (this.comparisonInstitutions().length > 0) {
- this.comparisonInstitutions.set([]);
- }
+ }
+
+ // If URL didn't specify institutions and list is currently empty, initialize defaults
+ if (!hasInstsFromUrl && this.comparisonInstitutions().length === 0) {
+ this.initializeDefaultInstitutions();
}
// Parse countries
@@ -1138,9 +1154,17 @@ export class UniTrendParentComponent implements OnInit {
// Add comparison institution
addInstitution(id: string, name: string) {
+ const cleanId = id.includes('/') ? id.split('/').pop() || id : id;
const current = this.comparisonInstitutions();
- if (!current.some((i: CompareItem) => i.id === id)) {
- this.comparisonInstitutions.set([...current, { id, name }]);
+ const exists = current.some((i: CompareItem) => {
+ const itemClean = i.id.includes('/')
+ ? i.id.split('/').pop() || i.id
+ : i.id;
+ return itemClean.toLowerCase() === cleanId.toLowerCase();
+ });
+ if (!exists) {
+ this.comparisonInstitutions.set([...current, { id: cleanId, name }]);
+ this.updateUrlParams();
}
this.searchQuery.set('');
this.searchResults.set([]);
@@ -1151,6 +1175,7 @@ export class UniTrendParentComponent implements OnInit {
this.comparisonInstitutions.set(
current.filter((i: CompareItem) => i.id !== id),
);
+ this.updateUrlParams();
}
// Add country or region
@@ -1175,6 +1200,7 @@ export class UniTrendParentComponent implements OnInit {
this.locationQuery.set('');
this.locationSearchResults.set([]);
this.loadTrendSuggestions();
+ this.updateUrlParams();
}
removeLocation(id: string, type: 'country' | 'continent') {
@@ -1190,6 +1216,7 @@ export class UniTrendParentComponent implements OnInit {
);
}
this.loadTrendSuggestions();
+ this.updateUrlParams();
}
// Add Top 3 Authors for a selected institution from institutions autocomplete
@@ -1230,6 +1257,7 @@ export class UniTrendParentComponent implements OnInit {
});
this.comparisonAuthors.set(updated);
this.isSuggestionsLoading.set(false);
+ this.updateUrlParams();
},
error: (err) => {
console.error('Failed to load top authors for institution:', err);
@@ -1246,12 +1274,14 @@ export class UniTrendParentComponent implements OnInit {
const current = this.comparisonAuthors();
if (!current.some((a) => a.id === shortId)) {
this.comparisonAuthors.set([...current, { id: shortId, name }]);
+ this.updateUrlParams();
}
}
removeAuthor(id: string) {
const current = this.comparisonAuthors();
this.comparisonAuthors.set(current.filter((a: CompareItem) => a.id !== id));
+ this.updateUrlParams();
}
// Scaling mode toggle (data reuses instantly)
diff --git a/webapp/src/app/shared/ui/author-selector/author-selector.component.ts b/webapp/src/app/shared/ui/author-selector/author-selector.component.ts
index 5874ff19..a54068b7 100644
--- a/webapp/src/app/shared/ui/author-selector/author-selector.component.ts
+++ b/webapp/src/app/shared/ui/author-selector/author-selector.component.ts
@@ -36,12 +36,12 @@ export class AuthorSelectorComponent {
const cleanId = id.includes('/') ? id.split('/').pop() || id : id;
const tab = this.activeTab();
if (tab === 'projects') {
- return `/person/${cleanId}/projects?page=0&size=10&sort_by=title&sort_direction=asc&search=`;
+ return `/inse-webapp/person/${cleanId}/projects?page=0&size=10&sort_by=title&sort_direction=asc&search=`;
}
if (tab === 'patents') {
- return `/person/${cleanId}/patents`;
+ return `/inse-webapp/person/${cleanId}/patents`;
}
- return `/person/${cleanId}/publications`;
+ return `/inse-webapp/person/${cleanId}/publications`;
}
onSelectPie(id: string, name: string): void {
diff --git a/webapp/src/app/shared/ui/institution-selector/institution-selector.component.ts b/webapp/src/app/shared/ui/institution-selector/institution-selector.component.ts
index e8ebd9d2..e2d0160a 100644
--- a/webapp/src/app/shared/ui/institution-selector/institution-selector.component.ts
+++ b/webapp/src/app/shared/ui/institution-selector/institution-selector.component.ts
@@ -51,12 +51,12 @@ export class InstitutionSelectorComponent {
const cleanId = id.includes('/') ? id.split('/').pop() || id : id;
const tab = this.activeTab();
if (tab === 'projects') {
- return `/institution/${cleanId}/projects?project_tab=bund&page=0&size=10&search=&sort_by=title&sort_direction=asc`;
+ return `/inse-webapp/institution/${cleanId}/projects?project_tab=bund&page=0&size=10&search=&sort_by=title&sort_direction=asc`;
}
if (tab === 'patents') {
- return `/institution/${cleanId}/patents?filter=all&sortBy=date&matchType=all&page=1`;
+ return `/inse-webapp/institution/${cleanId}/patents?filter=all&sortBy=date&matchType=all&page=1`;
}
- return `/institution/${cleanId}/publications`;
+ return `/inse-webapp/institution/${cleanId}/publications`;
}
onSelectPie(id: string, name: string): void {
@@ -92,8 +92,20 @@ export class InstitutionSelectorComponent {
isAlreadyAdded(id: string | undefined): boolean {
if (!id) return false;
- const isPrimary = this.primaryInstitution() === id;
- const isComp = this.comparisonInstitutions().some((i) => i.id === id);
+ const cleanTarget = id.includes('/') ? id.split('/').pop() || id : id;
+ const primaryId = this.primaryInstitution();
+ const cleanPrimary = primaryId
+ ? primaryId.includes('/')
+ ? primaryId.split('/').pop() || primaryId
+ : primaryId
+ : null;
+ const isPrimary = cleanPrimary?.toLowerCase() === cleanTarget.toLowerCase();
+ const isComp = this.comparisonInstitutions().some((i) => {
+ const cleanItem = i.id.includes('/')
+ ? i.id.split('/').pop() || i.id
+ : i.id;
+ return cleanItem.toLowerCase() === cleanTarget.toLowerCase();
+ });
return isPrimary || isComp;
}
}
From 2aea08ab315722dcdc7ec206141cf9a8dcf569a2 Mon Sep 17 00:00:00 2001
From: Kazgatari <56477241+Kazgatari@users.noreply.github.com>
Date: Sun, 19 Jul 2026 20:26:14 +0200
Subject: [PATCH 4/4] fixed project pie chart for sure now
---
.../university_ranking/trend_strategies.py | 62 +++++++++++++------
.../uni-trend-parent.component.ts | 3 +-
2 files changed, 43 insertions(+), 22 deletions(-)
diff --git a/service/src/main/inse/university_ranking/trend_strategies.py b/service/src/main/inse/university_ranking/trend_strategies.py
index 6aca6404..954c1e21 100644
--- a/service/src/main/inse/university_ranking/trend_strategies.py
+++ b/service/src/main/inse/university_ranking/trend_strategies.py
@@ -746,22 +746,37 @@ class ProjectsTrendStrategy(TrendStrategy):
primary_inst_id = DEFAULT_INSTITUTION_ID
primary_inst_name = DEFAULT_INSTITUTION_NAME
- query_institutions = []
- if institutions:
- query_institutions = [i.strip() for i in institutions]
- if primary_inst_id not in query_institutions:
- query_institutions.insert(0, primary_inst_id)
+ def clean_inst_id(id_str: str) -> str:
+ return id_str.split("/")[-1] if id_str and "/" in id_str else id_str
+
+ primary_inst_short = clean_inst_id(DEFAULT_INSTITUTION_ID)
+ primary_inst_full = f"https://openalex.org/{primary_inst_short}"
+
+ raw_insts = institutions or []
+ query_insts_short = [clean_inst_id(i) for i in raw_insts if i]
+ if primary_inst_short not in query_insts_short:
+ query_insts_short.insert(0, primary_inst_short)
+
+ # Preserve order while deduplicating
+ seen_insts = set()
+ dedup_inst_shorts = []
+ for s_id in query_insts_short:
+ if s_id not in seen_insts:
+ seen_insts.add(s_id)
+ dedup_inst_shorts.append(s_id)
+
+ query_institutions = dedup_inst_shorts
+ ids_to_resolve = [f"https://openalex.org/{i}" for i in query_institutions]
query_countries = countries or []
query_regions = regions or []
clean_countries = [c.strip().upper() for c in query_countries]
clean_regions = [r.strip() for r in query_regions]
- ids_to_resolve = list(set(query_institutions))
# 1. Resolve institution names & aliases, country names, and regions
async def fetch_institutions():
- names = {primary_inst_id: primary_inst_name}
+ names = {primary_inst_full: DEFAULT_INSTITUTION_NAME, primary_inst_short: DEFAULT_INSTITUTION_NAME}
codes = {}
aliases_map = {}
if not ids_to_resolve:
@@ -778,20 +793,27 @@ class ProjectsTrendStrategy(TrendStrategy):
)
for hit in res.get("hits", {}).get("hits", []):
source = hit["_source"]
- inst_id = source["id"]
- names[inst_id] = source.get("display_name", inst_id)
- codes[inst_id] = source.get("country_code", "")
-
- async def get_aliases(inst_id):
- try:
- return inst_id, await client.get_institution_aliases_by_oa_institution_id(inst_id)
- except Exception as e:
- logger.warning("Failed to get aliases for %s: %s", inst_id, e)
- return inst_id, [names.get(inst_id, inst_id)]
+ full_id = source["id"]
+ short_id = clean_inst_id(full_id)
+ d_name = source.get("display_name", full_id)
+ c_code = source.get("country_code", "")
+ names[full_id] = d_name
+ names[short_id] = d_name
+ codes[full_id] = c_code
+ codes[short_id] = c_code
- alias_results = await asyncio.gather(*(get_aliases(inst_id) for inst_id in ids_to_resolve))
- for inst_id, aliases in alias_results:
- aliases_map[inst_id] = aliases
+ async def get_aliases(inst_short_id):
+ try:
+ resolved = await client.get_institution_aliases_by_oa_institution_id(inst_short_id)
+ return inst_short_id, resolved or [names.get(inst_short_id, inst_short_id)]
+ except Exception as e:
+ logger.warning("Failed to get aliases for %s: %s", inst_short_id, e)
+ return inst_short_id, [names.get(inst_short_id, inst_short_id)]
+
+ alias_results = await asyncio.gather(*(get_aliases(i) for i in query_institutions))
+ for inst_short_id, aliases in alias_results:
+ aliases_map[inst_short_id] = aliases
+ aliases_map[f"https://openalex.org/{inst_short_id}"] = aliases
except Exception as e:
logger.warning("Failed to resolve institution details from ES: %s", e)
return names, codes, aliases_map
diff --git a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts
index 0557dc8f..5ab09e62 100644
--- a/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts
+++ b/webapp/src/app/modules/university-ranking/uni-trend-parent/uni-trend-parent.component.ts
@@ -397,8 +397,7 @@ export class UniTrendParentComponent implements OnInit {
if (s.entity_type === 'institution') {
if (cId === primaryInstCleanId) {
primaryInstSeries.push(s);
- }
- if (currentInstIds.has(cId)) {
+ } else if (currentInstIds.has(cId)) {
compInstSeries.push(s);
}
} else if (s.entity_type === 'country') {