implement Eu and Bund topics treemap
LocationBasedServices/smartguide/pipeline/head This commit looks good

This commit is contained in:
2026-08-06 12:16:49 +02:00
parent b21d8d3e88
commit 567b5ecd4f
8 changed files with 687 additions and 9 deletions
+18
View File
@@ -54,6 +54,8 @@ class DfgProjectTopic(BaseModel):
field: str | None = None
domain: str | None = None
project_count: int
field_project_count: int
subfield_project_count: int
keywords: list[DfgProjectKeyword]
@@ -65,6 +67,22 @@ class DfgProjectTopics(BaseModel):
topics: list[DfgProjectTopic]
class EuProjectTopics(BaseModel):
institution_id: str
organization_name: str
project_count: int
matched_project_count: int
topics: list[DfgProjectTopic]
class BundProjectTopics(BaseModel):
institution_id: str
organization_name: str
project_count: int
matched_project_count: int
topics: list[DfgProjectTopic]
class TopAuthor(BaseModel):
id: str | None = None
name: str
+44
View File
@@ -10,10 +10,12 @@ from inse.tags import Tags
from .model import (
BmbfProjectStatusStatistics,
BundProjectTopics,
DashboardStatistics,
DashboardStatisticValue,
DfgProjectStatusStatistics,
DfgProjectTopics,
EuProjectTopics,
EuProjectStatusStatistics,
TopAuthorStatistics,
TopicHeatmap,
@@ -22,9 +24,11 @@ from .model import (
from .service import (
get_dashboard_bmbf_project_statuses,
get_dashboard_bmbf_projects,
get_dashboard_bund_topics,
get_dashboard_dfg_project_statuses,
get_dashboard_dfg_projects,
get_dashboard_dfg_topics,
get_dashboard_eu_topics,
get_dashboard_eu_project_statuses,
get_dashboard_eu_projects,
get_dashboard_organization,
@@ -256,6 +260,46 @@ async def dashboard_dfg_project_topics(
)
@router.get(
"/projects/eu/topics",
operation_id="getDashboardEuProjectTopics",
response_model=EuProjectTopics,
)
async def dashboard_eu_project_topics(
from_year: int | None = Query(default=None, ge=1900, le=2100),
to_year: int | None = Query(default=None, ge=1900, le=2100),
session: Session = Depends(get_session),
access_token: AccessToken = auth_service.CurrentUserAccessTokenPayloadDep,
) -> EuProjectTopics:
organization = get_dashboard_organization(session, access_token)
return await get_dashboard_eu_topics(
organization.openalex_institution_id,
organization.name,
from_year=from_year,
to_year=to_year,
)
@router.get(
"/projects/bund/topics",
operation_id="getDashboardBundProjectTopics",
response_model=BundProjectTopics,
)
async def dashboard_bund_project_topics(
from_year: int | None = Query(default=None, ge=1900, le=2100),
to_year: int | None = Query(default=None, ge=1900, le=2100),
session: Session = Depends(get_session),
access_token: AccessToken = auth_service.CurrentUserAccessTokenPayloadDep,
) -> BundProjectTopics:
organization = get_dashboard_organization(session, access_token)
return await get_dashboard_bund_topics(
organization.openalex_institution_id,
organization.name,
from_year=from_year,
to_year=to_year,
)
@router.get(
"/top-authors",
operation_id="getDashboardTopAuthors",
+244
View File
@@ -1,4 +1,5 @@
import asyncio
import hashlib
import logging
import re
from collections import defaultdict
@@ -34,12 +35,14 @@ from inse.projects.model import (
from .institute_helper import get_openalex_institution
from .model import (
BmbfProjectStatusStatistics,
BundProjectTopics,
DashboardStatistics,
DfgProjectKeyword,
DashboardStatisticValue,
DfgProjectStatusStatistics,
DfgProjectTopic,
DfgProjectTopics,
EuProjectTopics,
EuProjectStatusStatistics,
TopAuthor,
TopAuthorStatistics,
@@ -860,6 +863,14 @@ async def get_dashboard_dfg_topics(
if keyword:
topic["keywords"].setdefault(keyword, set()).add(project_id)
field_project_ids: dict[str, set[str]] = defaultdict(set)
subfield_project_ids: dict[tuple[str, str], set[str]] = defaultdict(set)
for topic in topics.values():
field_name = str(topic["field"] or "")
subfield_name = str(topic["subfield"] or "")
field_project_ids[field_name].update(topic["project_ids"])
subfield_project_ids[(field_name, subfield_name)].update(topic["project_ids"])
topic_list = [
DfgProjectTopic(
id=topic["id"],
@@ -868,6 +879,12 @@ async def get_dashboard_dfg_topics(
field=topic["field"],
domain=topic["domain"],
project_count=len(topic["project_ids"]),
field_project_count=len(field_project_ids[str(topic["field"] or "")]),
subfield_project_count=len(
subfield_project_ids[
(str(topic["field"] or ""), str(topic["subfield"] or ""))
]
),
keywords=sorted(
[
DfgProjectKeyword(
@@ -891,6 +908,233 @@ async def get_dashboard_dfg_topics(
)
async def get_dashboard_eu_topics(
institution_id: str,
organization_name: str,
from_year: int | None = None,
to_year: int | None = None,
) -> EuProjectTopics:
normalized_id = _normalize_institution_id(institution_id)
project_ids = await _get_eu_project_ids_from_projects_service(
normalized_id,
from_year=from_year,
to_year=to_year,
)
topics: dict[str, dict[str, Any]] = {}
matched_project_ids: set[str] = set()
if project_ids:
mapping_indices = (
ESIndex.PROJECTS_CORDIS_EU_FP7_TOPICS_MAPPING,
ESIndex.PROJECTS_CORDIS_EU_H2020_TOPICS,
ESIndex.PROJECTS_CORDIS_EU_HEUROPE_TOPICS,
)
for mapping_index in mapping_indices:
async for hit in elasticsearch.scan(
index=str(mapping_index),
query={"terms": {"project_id": project_ids}},
source=["project_id", "keyword", "topic_matches"],
page_size=1000,
cluster=ESCluster.INSE,
):
source = hit.get("_source", {})
project_id = str(source.get("project_id") or "")
if not project_id:
continue
keyword = str(source.get("keyword") or "").strip()
matched_project_ids.add(project_id)
for match in source.get("topic_matches", []):
topic_id = str(match.get("topic_id") or "")
if not topic_id:
continue
topic = topics.setdefault(
topic_id,
{
"id": topic_id,
"name": str(match.get("topic_display_name") or topic_id),
"subfield": match.get("subfield"),
"field": match.get("field"),
"domain": match.get("domain"),
"project_ids": set(),
"keywords": {},
},
)
topic["project_ids"].add(project_id)
if keyword:
topic["keywords"].setdefault(keyword, set()).add(project_id)
field_project_ids: dict[str, set[str]] = defaultdict(set)
subfield_project_ids: dict[tuple[str, str], set[str]] = defaultdict(set)
for topic in topics.values():
field_name = str(topic["field"] or "")
subfield_name = str(topic["subfield"] or "")
field_project_ids[field_name].update(topic["project_ids"])
subfield_project_ids[(field_name, subfield_name)].update(topic["project_ids"])
topic_list = [
DfgProjectTopic(
id=topic["id"],
name=topic["name"],
subfield=topic["subfield"],
field=topic["field"],
domain=topic["domain"],
project_count=len(topic["project_ids"]),
field_project_count=len(field_project_ids[str(topic["field"] or "")]),
subfield_project_count=len(
subfield_project_ids[
(str(topic["field"] or ""), str(topic["subfield"] or ""))
]
),
keywords=sorted(
[
DfgProjectKeyword(
name=keyword,
project_count=len(keyword_project_ids),
)
for keyword, keyword_project_ids in topic["keywords"].items()
],
key=lambda entry: (-entry.project_count, entry.name),
),
)
for topic in topics.values()
]
topic_list.sort(key=lambda topic: (-topic.project_count, topic.name, topic.id))
return EuProjectTopics(
institution_id=normalized_id,
organization_name=organization_name,
project_count=len(project_ids),
matched_project_count=len(matched_project_ids),
topics=topic_list,
)
async def get_dashboard_bund_topics(
institution_id: str,
organization_name: str,
from_year: int | None = None,
to_year: int | None = None,
) -> BundProjectTopics:
normalized_id = _normalize_institution_id(institution_id)
period = _dashboard_period(from_year, to_year)
page_size = 1000
page_number = 0
project_ids: set[str] = set()
while True:
projects = await projects_service.search_bund_projects_with_filters(
institutions_search_client=InstitutionsSearchClient(),
executing_agency=None,
raw_oa_institution_id=_raw_institution_id(normalized_id),
title=None,
keywords=None,
funding_arts=None,
topic_ids=None,
filter_topic_ids=None,
funding_start_years=None,
funding_end_years=None,
active_from_year=period[0],
active_to_year=period[1],
countries=None,
page=page_number,
size=page_size,
sort_by="id",
sort_direction="asc",
fuzzy=False,
)
project_ids.update(
project.funding_code
for project in projects.elements
if project.funding_code
)
if len(project_ids) >= projects.total or not projects.elements:
break
page_number += 1
topics: dict[str, dict[str, Any]] = {}
matched_project_ids: set[str] = set()
if project_ids:
mapping_project_ids = sorted(
hashlib.sha256(project_id.encode("utf-8")).hexdigest()
for project_id in project_ids
)
async for hit in elasticsearch.scan(
index=str(ESIndex.PROJECTS_BUND_TOPICS),
query={"terms": {"project_id": mapping_project_ids}},
source=["project_id", "keyword", "topic_matches"],
page_size=1000,
cluster=ESCluster.INSE,
):
source = hit.get("_source", {})
project_id = str(source.get("project_id") or "")
if not project_id:
continue
keyword = str(source.get("keyword") or "").strip()
matched_project_ids.add(project_id)
for match in source.get("topic_matches", []):
topic_id = str(match.get("topic_id") or "")
if not topic_id:
continue
topic = topics.setdefault(
topic_id,
{
"id": topic_id,
"name": str(match.get("topic_display_name") or topic_id),
"subfield": match.get("subfield"),
"field": match.get("field"),
"domain": match.get("domain"),
"project_ids": set(),
"keywords": {},
},
)
topic["project_ids"].add(project_id)
if keyword:
topic["keywords"].setdefault(keyword, set()).add(project_id)
field_project_ids: dict[str, set[str]] = defaultdict(set)
subfield_project_ids: dict[tuple[str, str], set[str]] = defaultdict(set)
for topic in topics.values():
field_name = str(topic["field"] or "")
subfield_name = str(topic["subfield"] or "")
field_project_ids[field_name].update(topic["project_ids"])
subfield_project_ids[(field_name, subfield_name)].update(topic["project_ids"])
topic_list = [
DfgProjectTopic(
id=topic["id"],
name=topic["name"],
subfield=topic["subfield"],
field=topic["field"],
domain=topic["domain"],
project_count=len(topic["project_ids"]),
field_project_count=len(field_project_ids[str(topic["field"] or "")]),
subfield_project_count=len(
subfield_project_ids[
(str(topic["field"] or ""), str(topic["subfield"] or ""))
]
),
keywords=sorted(
[
DfgProjectKeyword(
name=keyword,
project_count=len(keyword_project_ids),
)
for keyword, keyword_project_ids in topic["keywords"].items()
],
key=lambda entry: (-entry.project_count, entry.name),
),
)
for topic in topics.values()
]
topic_list.sort(key=lambda topic: (-topic.project_count, topic.name, topic.id))
return BundProjectTopics(
institution_id=normalized_id,
organization_name=organization_name,
project_count=len(project_ids),
matched_project_count=len(matched_project_ids),
topics=topic_list,
)
async def _get_dfg_project_ids_from_projects_service(
institution_id: str,
from_year: int | None = None,
@@ -1,4 +1,5 @@
from datetime import datetime
import hashlib
from types import SimpleNamespace
from unittest.mock import AsyncMock, patch
@@ -15,8 +16,10 @@ from inse.dashboard.service import (
_reconcile_project_status_counts,
_top_news_authors,
get_dashboard_bmbf_projects,
get_dashboard_bund_topics,
get_dashboard_dfg_projects,
get_dashboard_eu_projects,
get_dashboard_eu_topics,
get_dashboard_organization,
get_dashboard_persons,
get_dashboard_publications,
@@ -31,6 +34,7 @@ from inse.models.openalex.meta import Meta
from inse.persons.model import CustomAuthorsListResponse
from inse.projects.model import (
BundProjectPage,
BundProjectSummary,
DfgProjectPage,
DfgProjectSummary,
EuCordisProjectSearchPage,
@@ -154,6 +158,155 @@ async def test_dfg_topic_project_ids_use_paginated_projects_service():
assert first_call.kwargs["funding_end_years"][0] == "2020"
@pytest.mark.anyio
async def test_eu_topics_scan_all_programme_indices_and_deduplicate_projects():
scanned_indices: list[str] = []
async def scan(**kwargs):
scanned_indices.append(kwargs["index"])
if kwargs["index"] == str(ESIndex.PROJECTS_CORDIS_EU_FP7_TOPICS_MAPPING):
yield {
"_source": {
"project_id": "P1",
"keyword": "AI",
"topic_matches": [
{
"topic_id": "T1",
"topic_display_name": "Artificial Intelligence",
"field": "Computer Science",
"subfield": "AI",
"domain": "Physical Sciences",
}
],
}
}
yield {
"_source": {
"project_id": "P1",
"keyword": "Robotics",
"topic_matches": [
{
"topic_id": "T2",
"topic_display_name": "Robotics",
"field": "Computer Science",
"subfield": "Robotics",
"domain": "Physical Sciences",
}
],
}
}
if kwargs["index"] == str(ESIndex.PROJECTS_CORDIS_EU_H2020_TOPICS):
yield {
"_source": {
"project_id": "P2",
"keyword": "AI",
"topic_matches": [
{
"topic_id": "T1",
"topic_display_name": "Artificial Intelligence",
"field": "Computer Science",
"subfield": "AI",
"domain": "Physical Sciences",
}
],
}
}
with patch(
"inse.dashboard.service._get_eu_project_ids_from_projects_service",
new=AsyncMock(return_value=["P1", "P2", "P3"]),
), patch("inse.dashboard.service.elasticsearch.scan", new=scan):
result = await get_dashboard_eu_topics(
ORG_INSTITUTION_ID,
"Example Org",
from_year=2022,
to_year=2026,
)
assert scanned_indices == [
str(ESIndex.PROJECTS_CORDIS_EU_FP7_TOPICS_MAPPING),
str(ESIndex.PROJECTS_CORDIS_EU_H2020_TOPICS),
str(ESIndex.PROJECTS_CORDIS_EU_HEUROPE_TOPICS),
]
assert result.project_count == 3
assert result.matched_project_count == 2
assert result.topics[0].project_count == 2
assert result.topics[0].keywords[0].project_count == 2
assert {topic.field_project_count for topic in result.topics} == {2}
assert {topic.name: topic.subfield_project_count for topic in result.topics} == {
"Artificial Intelligence": 2,
"Robotics": 1,
}
@pytest.mark.anyio
async def test_bund_topics_use_mapping_index_and_unique_hierarchy_counts():
project_page = BundProjectPage(
elements=[
BundProjectSummary(funding_code="B1"),
BundProjectSummary(funding_code="B2"),
],
total=2,
page=0,
size=1000,
)
async def scan(**kwargs):
assert kwargs["index"] == str(ESIndex.PROJECTS_BUND_TOPICS)
mapping_ids = {
funding_code: hashlib.sha256(funding_code.encode("utf-8")).hexdigest()
for funding_code in ("B1", "B2")
}
assert kwargs["query"] == {
"terms": {"project_id": sorted(mapping_ids.values())}
}
for project_id, topic_id, topic_name, subfield in (
(mapping_ids["B1"], "T1", "Artificial Intelligence", "AI"),
(mapping_ids["B1"], "T2", "Robotics", "Robotics"),
(mapping_ids["B2"], "T1", "Artificial Intelligence", "AI"),
):
yield {
"_source": {
"project_id": project_id,
"keyword": topic_name,
"topic_matches": [
{
"topic_id": topic_id,
"topic_display_name": topic_name,
"field": "Computer Science",
"subfield": subfield,
"domain": "Physical Sciences",
}
],
}
}
with patch(
"inse.dashboard.service.projects_service.search_bund_projects_with_filters",
new=AsyncMock(return_value=project_page),
) as mocked_projects, patch(
"inse.dashboard.service.elasticsearch.scan",
new=scan,
):
result = await get_dashboard_bund_topics(
ORG_INSTITUTION_ID,
"Example Org",
from_year=2022,
to_year=2026,
)
project_call = mocked_projects.await_args
assert project_call.kwargs["active_from_year"] == 2022
assert project_call.kwargs["active_to_year"] == 2026
assert result.project_count == 2
assert result.matched_project_count == 2
assert {topic.field_project_count for topic in result.topics} == {2}
assert {topic.name: topic.subfield_project_count for topic in result.topics} == {
"Artificial Intelligence": 2,
"Robotics": 1,
}
@pytest.mark.anyio
async def test_dashboard_statistics_counts_organization_data_and_all_projects():
async def search(**kwargs):
@@ -59,6 +59,8 @@ export interface DfgProjectTopic {
field?: string | null;
domain?: string | null;
project_count: number;
field_project_count: number;
subfield_project_count: number;
keywords: DfgProjectKeyword[];
}
@@ -75,6 +77,9 @@ export interface DfgProjectTopics {
topics: DfgProjectTopic[];
}
export interface EuProjectTopics extends DfgProjectTopics {}
export interface BundProjectTopics extends DfgProjectTopics {}
export interface TopAuthor {
id?: string | null;
name: string;
@@ -202,6 +207,24 @@ export class DashboardStatisticsService {
);
}
getEuProjectTopics(
period: DashboardPeriodBounds = {},
): Observable<EuProjectTopics> {
return this.httpClient.get<EuProjectTopics>(
`${this.apiConfiguration?.basePath ?? ''}/api/dashboard/projects/eu/topics`,
{ params: this.periodParams(period) },
);
}
getBundProjectTopics(
period: DashboardPeriodBounds = {},
): Observable<BundProjectTopics> {
return this.httpClient.get<BundProjectTopics>(
`${this.apiConfiguration?.basePath ?? ''}/api/dashboard/projects/bund/topics`,
{ params: this.periodParams(period) },
);
}
getTopAuthors(
period: DashboardPeriodBounds = {},
): Observable<TopAuthorStatistics> {
@@ -317,6 +317,92 @@
</section>
}
@if (euTopicsLoading || euTopicsError || euProjectTopics) {
<section class="topic-heatmap-section">
<header class="topic-heatmap-header">
<div>
<h2>EU-Projekt-Topics</h2>
<p>
Gematchte EU-Projekte nach Field, Subfield und Topic. Ein Klick
auf ein Topic zeigt die zugehörigen Keywords.
</p>
</div>
@if (euProjectTopics) {
<p class="dfg-topic-summary">
{{ euProjectTopics.matched_project_count | number }} von
{{ euProjectTopics.project_count | number }} Projekten gematcht
</p>
}
</header>
@if (euTopicsLoading) {
<div class="topic-heatmap-loading" role="status" aria-live="polite">
<app-loading
text="EU-Topics werden geladen …"
icon="account_tree"
size="72"
diameter="72"></app-loading>
</div>
} @else if (euTopicsError) {
<p class="statistics-error">
Die EU-Topic-Treemap konnte nicht geladen werden.
</p>
} @else {
<app-topic-treemap
[data]="euTopicTreemap"
[selectedNodeId]="selectedEuTopicTreemapNode"
countLabel="EU-Projekte"
[showCountInTooltip]="false"
(selectedNodeIdChange)="onEuTopicTreemapNodeChange($event)"
(topicSelect)="onEuTopicTreemapTopicSelect($event)">
</app-topic-treemap>
}
</section>
}
@if (bundTopicsLoading || bundTopicsError || bundProjectTopics) {
<section class="topic-heatmap-section">
<header class="topic-heatmap-header">
<div>
<h2>BUND-Projekt-Topics</h2>
<p>
Gematchte BUND-Projekte nach Field, Subfield und Topic. Ein Klick
auf ein Topic zeigt die zugehörigen Keywords.
</p>
</div>
@if (bundProjectTopics) {
<p class="dfg-topic-summary">
{{ bundProjectTopics.matched_project_count | number }} von
{{ bundProjectTopics.project_count | number }} Projekten gematcht
</p>
}
</header>
@if (bundTopicsLoading) {
<div class="topic-heatmap-loading" role="status" aria-live="polite">
<app-loading
text="BUND-Topics werden geladen …"
icon="account_tree"
size="72"
diameter="72"></app-loading>
</div>
} @else if (bundTopicsError) {
<p class="statistics-error">
Die BUND-Topic-Treemap konnte nicht geladen werden.
</p>
} @else {
<app-topic-treemap
[data]="bundTopicTreemap"
[selectedNodeId]="selectedBundTopicTreemapNode"
countLabel="BUND-Projekte"
[showCountInTooltip]="false"
(selectedNodeIdChange)="onBundTopicTreemapNodeChange($event)"
(topicSelect)="onBundTopicTreemapTopicSelect($event)">
</app-topic-treemap>
}
</section>
}
@if (topAuthorsLoading || topAuthorsError || hasTopAuthorData()) {
<section class="top-authors-section">
<header class="top-authors-header">
@@ -18,6 +18,7 @@ import {
} from './topic-wordcloud-dialog/topic-wordcloud-dialog.component';
import {
BmbfProjectStatusStatistics,
BundProjectTopics,
DashboardPeriodBounds,
DashboardStatisticValue,
DashboardStatistics,
@@ -26,6 +27,7 @@ import {
DfgProjectTopic,
DfgProjectTopics,
EuProjectStatusStatistics,
EuProjectTopics,
TopAuthor,
TopAuthorStatistics,
} from './dashboard-statistics.service';
@@ -96,6 +98,14 @@ export class DashboardComponent implements OnInit {
dfgTopicTreemap?: TopicTreemapData;
dfgTopicsLoading = false;
dfgTopicsError = false;
euProjectTopics?: EuProjectTopics;
euTopicTreemap?: TopicTreemapData;
euTopicsLoading = false;
euTopicsError = false;
bundProjectTopics?: BundProjectTopics;
bundTopicTreemap?: TopicTreemapData;
bundTopicsLoading = false;
bundTopicsError = false;
euProjectStatuses?: EuProjectStatusStatistics;
euProjectStatusesLoading = false;
euProjectStatusesError = false;
@@ -112,6 +122,8 @@ export class DashboardComponent implements OnInit {
dashboardToYear = this.topicTreemapMaxYear;
selectedTopicTreemapNode?: string;
selectedDfgTopicTreemapNode?: string;
selectedEuTopicTreemapNode?: string;
selectedBundTopicTreemapNode?: string;
private topicTreemapReloadQueued = false;
private topicTreemapRequestId = 0;
@@ -128,6 +140,8 @@ export class DashboardComponent implements OnInit {
this.loadTopAuthors();
this.loadTopicTreemap();
this.loadDfgProjectTopics();
this.loadEuProjectTopics();
this.loadBundProjectTopics();
this.loadEuProjectStatuses();
this.loadBmbfProjectStatuses();
this.loadDfgProjectStatuses();
@@ -245,10 +259,12 @@ export class DashboardComponent implements OnInit {
([subfieldName, group]) => ({
id: `${fieldName}::${subfieldName}`,
name: subfieldName,
total: group.topics.reduce(
(sum, topic) => sum + topic.project_count,
0,
),
total:
group.topics[0]?.subfield_project_count ??
group.topics.reduce(
(sum, topic) => sum + topic.project_count,
0,
),
values: [],
topics: group.topics.map((topic) => ({
id: topic.id,
@@ -261,10 +277,12 @@ export class DashboardComponent implements OnInit {
return {
id: fieldName,
name: fieldName,
total: mappedSubfields.reduce(
(sum, subfield) => sum + subfield.total,
0,
),
total:
[...subfields.values()][0]?.topics[0]?.field_project_count ??
mappedSubfields.reduce(
(sum, subfield) => sum + subfield.total,
0,
),
values: [],
subfields: mappedSubfields,
};
@@ -378,6 +396,62 @@ export class DashboardComponent implements OnInit {
);
}
onEuTopicTreemapNodeChange(nodeId: string | undefined): void {
this.selectedEuTopicTreemapNode = nodeId;
}
onEuTopicTreemapTopicSelect(topic: TopicTreemapTopicSelect): void {
const euTopic = this.euProjectTopics?.topics.find(
(entry) => entry.id === topic.topicId,
);
if (!euTopic) return;
this.dialog.open<TopicWordCloudDialogComponent, TopicWordCloudDialogData>(
TopicWordCloudDialogComponent,
{
width: '85vw',
maxWidth: '92vw',
data: {
...topic,
source: 'eu',
words: euTopic.keywords.map((keyword) => ({
id: keyword.name,
name: keyword.name,
count: keyword.project_count,
})),
},
},
);
}
onBundTopicTreemapNodeChange(nodeId: string | undefined): void {
this.selectedBundTopicTreemapNode = nodeId;
}
onBundTopicTreemapTopicSelect(topic: TopicTreemapTopicSelect): void {
const bundTopic = this.bundProjectTopics?.topics.find(
(entry) => entry.id === topic.topicId,
);
if (!bundTopic) return;
this.dialog.open<TopicWordCloudDialogComponent, TopicWordCloudDialogData>(
TopicWordCloudDialogComponent,
{
width: '85vw',
maxWidth: '92vw',
data: {
...topic,
source: 'bund',
words: bundTopic.keywords.map((keyword) => ({
id: keyword.name,
name: keyword.name,
count: keyword.project_count,
})),
},
},
);
}
onTopicTreemapTopicSelect(topic: TopicTreemapTopicSelect): void {
const period = this.selectedPeriodBounds();
this.dialog.open<TopicWordCloudDialogComponent, TopicWordCloudDialogData>(
@@ -469,6 +543,8 @@ export class DashboardComponent implements OnInit {
this.loadTopAuthors();
this.loadTopicTreemap();
this.loadDfgProjectTopics();
this.loadEuProjectTopics();
this.loadBundProjectTopics();
this.loadEuProjectStatuses();
this.loadBmbfProjectStatuses();
this.loadDfgProjectStatuses();
@@ -552,6 +628,40 @@ export class DashboardComponent implements OnInit {
});
}
private loadEuProjectTopics(): void {
this.euTopicsLoading = true;
this.euTopicsError = false;
this.statisticsService
.getEuProjectTopics(this.selectedPeriodBounds())
.pipe(finalize(() => (this.euTopicsLoading = false)))
.subscribe({
next: (topics) => {
this.euProjectTopics = topics;
this.euTopicTreemap = this.buildDfgTopicTreemapData(topics);
},
error: () => {
this.euTopicsError = true;
},
});
}
private loadBundProjectTopics(): void {
this.bundTopicsLoading = true;
this.bundTopicsError = false;
this.statisticsService
.getBundProjectTopics(this.selectedPeriodBounds())
.pipe(finalize(() => (this.bundTopicsLoading = false)))
.subscribe({
next: (topics) => {
this.bundProjectTopics = topics;
this.bundTopicTreemap = this.buildDfgTopicTreemapData(topics);
},
error: () => {
this.bundTopicsError = true;
},
});
}
private loadEuProjectStatuses(): void {
this.euProjectStatusesLoading = true;
this.euProjectStatusesError = false;
@@ -23,7 +23,7 @@ export interface TopicWordCloudDialogData {
fromYear?: number;
toYear?: number;
words?: TopicWordCloudWord[];
source?: 'publications' | 'dfg';
source?: 'publications' | 'dfg' | 'eu' | 'bund';
}
interface DisplayWord extends TopicWordCloudWord {