diff --git a/service/src/main/inse/dashboard/service.py b/service/src/main/inse/dashboard/service.py
index 39bf6f91..5df7eb3e 100644
--- a/service/src/main/inse/dashboard/service.py
+++ b/service/src/main/inse/dashboard/service.py
@@ -36,18 +36,6 @@ TOPIC_HEATMAP_YEARS = 5
WorksPeriod = Literal["all_time", "last_5_years"]
logger = logging.getLogger(__name__)
-DFG_INSTITUTION_FIELDS = [
- "Antragstellende Institution",
- "Mitantragstellende Institution",
- "Beteiligte Einrichtung",
- "Beteiligte Hochschule",
- "Beteiligte Institution",
- "IGK-Partnerinstitution",
- "Partnerorganisation",
- "Unternehmen",
-]
-
-
def _total(response: dict[str, Any]) -> int:
total = response.get("hits", {}).get("total", 0)
if isinstance(total, dict):
@@ -249,7 +237,7 @@ async def get_dashboard_dfg_projects(
normalized_id = _normalize_institution_id(institution_id)
aliases = await _institution_aliases(normalized_id, organization_name)
response = await elasticsearch.search(
- index=ESIndex.PROJECTS_DFG_ALL,
+ index=ESIndex.DFG_PROJECTS_V2,
query=_dfg_institution_query(aliases),
size=0,
track_total_hits=True,
@@ -317,8 +305,42 @@ def _dfg_institution_query(aliases: list[str]) -> dict[str, Any]:
return {
"bool": {
"should": [
- _alias_match_query(field, aliases)
- for field in DFG_INSTITUTION_FIELDS
+ {
+ "nested": {
+ "path": "institutions",
+ "query": {
+ "bool": {
+ "should": [
+ _alias_match_query(
+ "institutions.institute_name_de", aliases
+ ),
+ _alias_match_query(
+ "institutions.institute_name_en", aliases
+ ),
+ ],
+ "minimum_should_match": 1,
+ }
+ },
+ }
+ },
+ {
+ "nested": {
+ "path": "persons",
+ "query": {
+ "bool": {
+ "should": [
+ _alias_match_query(
+ "persons.affiliation_de", aliases
+ ),
+ _alias_match_query(
+ "persons.affiliation_en", aliases
+ ),
+ ],
+ "minimum_should_match": 1,
+ }
+ },
+ }
+ },
],
"minimum_should_match": 1,
}
diff --git a/service/src/main/inse/dashboard/test_service.py b/service/src/main/inse/dashboard/test_service.py
index 12c74d02..cec617e8 100644
--- a/service/src/main/inse/dashboard/test_service.py
+++ b/service/src/main/inse/dashboard/test_service.py
@@ -58,20 +58,25 @@ async def test_dashboard_statistics_counts_organization_data_and_all_projects():
"bmbf_projects": 5,
}
calls = mocked_search.await_args_list
- assert calls[0].kwargs["index"] == config.settings.openalex_works_search_index
- assert calls[0].kwargs["query"]["nested"]["query"]["term"] == {
+ calls_by_index = {call.kwargs["index"]: call for call in calls}
+ works_call = calls_by_index[config.settings.openalex_works_search_index]
+ authors_call = calls_by_index[ESIndex.OPENALEX_AUTHORS]
+ eu_call = calls_by_index[ESIndex.CORDIS_EU_ORGANIZATIONS_WILDCARD]
+ bmbf_call = calls_by_index[ESIndex.PROJECTS_BUND_V1]
+ dfg_call = calls_by_index[ESIndex.DFG_PROJECTS_V2]
+ assert works_call.kwargs["query"]["nested"]["query"]["term"] == {
"authorships.institutions.id": ORG_INSTITUTION_ID
}
- assert calls[1].kwargs["query"]["nested"]["query"]["term"] == {
- "affiliations.institution.id": ORG_INSTITUTION_ID
+ assert authors_call.kwargs["query"]["bool"]["should"][0]["bool"]["filter"][
+ 0
+ ]["nested"]["query"]["match_phrase"] == {
+ "last_known_institutions.id": ORG_INSTITUTION_ID
}
- assert all(call.kwargs["cluster"] == ESCluster.INSE for call in calls[2:])
- assert [call.kwargs["index"] for call in calls[2:]] == [
- ESIndex.CORDIS_EU_ORGANIZATIONS_WILDCARD,
- ESIndex.PROJECTS_BUND_V1,
- ESIndex.PROJECTS_DFG_ALL,
- ]
- assert calls[2].kwargs["body"]["query"] == {
+ assert all(
+ call.kwargs["cluster"] == ESCluster.INSE
+ for call in [eu_call, bmbf_call, dfg_call]
+ )
+ assert eu_call.kwargs["body"]["query"] == {
"terms": {
"name.keyword": [
"EXAMPLE ORG",
@@ -80,22 +85,25 @@ async def test_dashboard_statistics_counts_organization_data_and_all_projects():
]
}
}
- assert calls[3].kwargs["query"]["bool"]["minimum_should_match"] == 1
- assert calls[3].kwargs["query"]["bool"]["should"][0]["match"] == {
+ assert bmbf_call.kwargs["query"]["bool"]["minimum_should_match"] == 1
+ assert bmbf_call.kwargs["query"]["bool"]["should"][0]["match"] == {
"Zuwendungsempfänger": {
"query": "Example Org",
"operator": "and",
}
}
- assert calls[4].kwargs["query"]["bool"]["minimum_should_match"] == 1
- assert calls[4].kwargs["query"]["bool"]["should"][0]["bool"]["should"][0][
- "match"
- ] == {
- "Antragstellende Institution": {
+ dfg_query = dfg_call.kwargs["query"]
+ assert dfg_query["bool"]["minimum_should_match"] == 1
+ assert dfg_query["bool"]["should"][0]["nested"]["path"] == "institutions"
+ assert dfg_query["bool"]["should"][0]["nested"]["query"]["bool"]["should"][
+ 0
+ ]["bool"]["should"][0]["match"] == {
+ "institutions.institute_name_de": {
"query": "Example Org",
"operator": "and",
}
}
+ assert dfg_query["bool"]["should"][1]["nested"]["path"] == "persons"
@pytest.mark.anyio
@@ -181,7 +189,7 @@ async def test_top_authors_maps_works_patents_and_news_without_project_queries()
call
for call in mocked_search.await_args_list
if call.kwargs["index"]
- in {ESIndex.PROJECTS_DFG_ALL, ESIndex.PROJECTS_BUND_V1}
+ in {ESIndex.DFG_PROJECTS_V2, ESIndex.PROJECTS_BUND_V1}
]
assert project_calls == []
eu_calls = [
diff --git a/service/src/main/inse/integrations/elasticsearch.py b/service/src/main/inse/integrations/elasticsearch.py
index b58065cf..77afd124 100644
--- a/service/src/main/inse/integrations/elasticsearch.py
+++ b/service/src/main/inse/integrations/elasticsearch.py
@@ -101,6 +101,7 @@ def _index_to_cluster(index: ESIndex) -> Optional[ESCluster]:
ESIndex.CORDIS_EU_PUBLICATIONS_WILDCARD,
ESIndex.PROJECTS_BUND_V1,
ESIndex.PROJECTS_DFG_ALL,
+ ESIndex.DFG_PROJECTS_V2,
}:
return ESCluster.INSE
else:
diff --git a/service/src/main/inse/model.py b/service/src/main/inse/model.py
index a417cb81..5265720b 100644
--- a/service/src/main/inse/model.py
+++ b/service/src/main/inse/model.py
@@ -61,6 +61,7 @@ class ESIndex(StrEnum):
PROJECTS_BUND_V1 = "projects_bund_v1"
PROJECTS_DFG_ALL = "projects_dfg_all"
+ DFG_PROJECTS_V2 = "dfg_projects_2.0"
CORDIS_EU_ORGANIZATIONS_WILDCARD = "cordis_eu_*_organizations"
CORDIS_EU_PROJECTS_WILDCARD = "cordis_eu_*_projects"
diff --git a/webapp/src/app/modules/dashboard/topic-heatmap/topic-heatmap.component.ts b/webapp/src/app/modules/dashboard/topic-heatmap/topic-heatmap.component.ts
index 981236db..34317472 100644
--- a/webapp/src/app/modules/dashboard/topic-heatmap/topic-heatmap.component.ts
+++ b/webapp/src/app/modules/dashboard/topic-heatmap/topic-heatmap.component.ts
@@ -3,6 +3,7 @@ import { MatDialog } from '@angular/material/dialog';
import { EChartsOption } from 'echarts';
import { NgxEchartsDirective } from 'ngx-echarts';
+import { topicHierarchyColor } from '../../../resolvers/utils/topic-colors';
import { TopicHeatmap } from '../dashboard-statistics.service';
import {
TopicWordCloudDialogComponent,
@@ -17,22 +18,11 @@ import {
})
export class TopicHeatmapComponent implements OnChanges {
private readonly dialog = inject(MatDialog);
+ private readonly fieldColorOpacity = 0.78;
@Input() heatmap?: TopicHeatmap;
@Input() loading = false;
options: EChartsOption = {};
- private readonly colors = [
- '#2563eb',
- '#059669',
- '#d97706',
- '#dc2626',
- '#7c3aed',
- '#0284c7',
- '#ea580c',
- '#4f46e5',
- '#0f766e',
- '#be123c',
- ];
ngOnChanges(): void {
this.options = this.buildOptions();
@@ -60,49 +50,118 @@ export class TopicHeatmapComponent implements OnChanges {
private buildOptions(): EChartsOption {
const fields = this.heatmap?.fields ?? [];
- const data = fields.map((field) => ({
- id: field.id,
- name: field.name,
- value: field.total || this.totalCount(field.values),
- label: {
- show: true,
- formatter: (params: any) =>
- `${params.name}\n${this.formatCount(params.value)}`,
- color: '#ffffff',
- fontWeight: 700,
- lineHeight: 18,
- overflow: 'truncate' as const,
- },
- children: (field.subfields ?? [])
- .filter((subfield) => subfield.total > 0)
- .map((subfield) => ({
- id: subfield.id,
- name: subfield.name,
- value: subfield.total,
- fieldName: field.name,
- children: (subfield.topics ?? [])
- .filter((topic) => topic.total > 0)
- .map((topic) => ({
- id: topic.id,
- name: topic.name,
- value: topic.total,
- fieldName: field.name,
- subfieldName: subfield.name,
- })),
- })),
- }));
+ const data = fields.map((field) => {
+ const fieldColor = topicHierarchyColor({
+ field_id: field.id,
+ field_name: field.name,
+ });
+
+ return {
+ id: field.id,
+ name: field.name,
+ value: field.total || this.totalCount(field.values),
+ itemStyle: {
+ color: fieldColor,
+ opacity: this.fieldColorOpacity,
+ },
+ emphasis: {
+ itemStyle: {
+ color: fieldColor,
+ opacity: this.fieldColorOpacity,
+ },
+ },
+ label: {
+ show: true,
+ formatter: (params: any) =>
+ `${params.name}\n${this.formatCount(params.value)}`,
+ color: '#ffffff',
+ fontWeight: 700,
+ lineHeight: 18,
+ overflow: 'truncate' as const,
+ },
+ children: (field.subfields ?? [])
+ .filter((subfield) => subfield.total > 0)
+ .map((subfield) => ({
+ id: subfield.id,
+ name: subfield.name,
+ value: subfield.total,
+ fieldName: field.name,
+ itemStyle: {
+ color: fieldColor,
+ opacity: this.fieldColorOpacity,
+ },
+ emphasis: {
+ itemStyle: {
+ color: fieldColor,
+ opacity: this.fieldColorOpacity,
+ },
+ },
+ children: (subfield.topics ?? [])
+ .filter((topic) => topic.total > 0)
+ .map((topic) => ({
+ id: topic.id,
+ name: topic.name,
+ value: topic.total,
+ fieldName: field.name,
+ subfieldName: subfield.name,
+ itemStyle: {
+ color: fieldColor,
+ opacity: this.fieldColorOpacity,
+ },
+ emphasis: {
+ itemStyle: {
+ color: fieldColor,
+ opacity: this.fieldColorOpacity,
+ },
+ },
+ })),
+ })),
+ };
+ });
return {
tooltip: {
+ trigger: 'item',
+ confine: true,
+ backgroundColor: '#ffffff',
+ borderColor: '#d8cafe',
+ borderWidth: 1,
+ padding: 0,
+ extraCssText:
+ 'max-width: 360px; border-radius: 12px; box-shadow: 0 14px 36px rgba(16, 26, 61, 0.18);',
formatter: (params: any) => {
const count = Number(params.value ?? 0);
- const field = params.data?.fieldName
- ? `
Field: ${params.data.fieldName}`
+ const name = this.escapeHtml(String(params.name ?? ''));
+ const fieldName = params.data?.fieldName
+ ? this.escapeHtml(String(params.data.fieldName))
: '';
- const subfield = params.data?.subfieldName
- ? `
Subfield: ${params.data.subfieldName}`
+ const subfieldName = params.data?.subfieldName
+ ? this.escapeHtml(String(params.data.subfieldName))
: '';
- return `${params.name}${field}${subfield}
${count} Publikationen`;
+ const hierarchy = [fieldName, subfieldName]
+ .filter(Boolean)
+ .map(
+ (item) =>
+ `${item}`,
+ )
+ .join('›');
+
+ return `
+
- {{ data.fieldName }} - @if (data.subfieldName) { - · {{ data.subfieldName }} - } -
+Die wichtigsten Begriffe zum ausgewählten Forschungsthema
+Die Schriftgröße entspricht der Anzahl der Publikationen.
+