Add funder publication URLs from Elasticsearch
This commit is contained in:
@@ -7,15 +7,15 @@
|
||||
} @else {
|
||||
<div class="funding-container">
|
||||
<div class="funding-summary">
|
||||
<div class="summary-card">
|
||||
<span class="summary-value">{{ getUniquePublicationCount() }}</span>
|
||||
<span class="summary-label"> Einzigartige Publikationen</span>
|
||||
<p class="summary-line">
|
||||
<span class="summary-value">{{ getUniquePublicationCount() }}</span>
|
||||
<span class="summary-label"> Einzigartige Publikationen</span>
|
||||
</p>
|
||||
<p class="summary-line">
|
||||
<span class="summary-value">{{ filteredFunders.length }}</span>
|
||||
<span class="summary-label"> Förderer</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="summary-card">
|
||||
<span class="summary-value">{{ filteredFunders.length }}</span>
|
||||
<span class="summary-label"> Förderer</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Filter Buttons -->
|
||||
<div class="filter-bar">
|
||||
@@ -92,7 +92,7 @@
|
||||
<ul class="publication-list">
|
||||
@for (id of getSelectedPublicationIdsPage(); track id) {
|
||||
<li>
|
||||
<a [href]="id" target="_blank" rel="noopener" (click)="openPublication($event, id)">{{ id }}</a>
|
||||
<a [href]="getPublicationUrl(id)" target="_blank" rel="noopener" (click)="openPublication($event, id)">{{ id }}</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
|
||||
@@ -17,7 +17,6 @@ export class PersonFundingComponent implements OnInit {
|
||||
private initialSelectedFunderKey: string | null = null;
|
||||
private initialPublicationPage = 1;
|
||||
private initialFunderListPage = 1;
|
||||
private publicationUrlCache = new Map<string, string>();
|
||||
|
||||
funders: any[] = [];
|
||||
filteredFunders: any[] = [];
|
||||
@@ -198,9 +197,9 @@ export class PersonFundingComponent implements OnInit {
|
||||
this.updateQueryParams();
|
||||
}
|
||||
|
||||
async openPublication(event: MouseEvent, publicationId: string): Promise<void> {
|
||||
openPublication(event: MouseEvent, publicationId: string): void {
|
||||
event.preventDefault();
|
||||
const url = await this.resolvePreferredPublicationUrl(publicationId);
|
||||
const url = this.getPublicationUrl(publicationId);
|
||||
window.open(url, '_blank', 'noopener');
|
||||
}
|
||||
|
||||
@@ -234,42 +233,8 @@ export class PersonFundingComponent implements OnInit {
|
||||
return allIds.size;
|
||||
}
|
||||
|
||||
private async resolvePreferredPublicationUrl(publicationId: string): Promise<string> {
|
||||
const cached = this.publicationUrlCache.get(publicationId);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
const fallbackUrl = publicationId;
|
||||
const workId = publicationId.replace('https://openalex.org/', '').trim();
|
||||
if (!workId) {
|
||||
return fallbackUrl;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`https://api.openalex.org/works/${encodeURIComponent(workId)}`);
|
||||
if (!response.ok) {
|
||||
return fallbackUrl;
|
||||
}
|
||||
|
||||
const work = await response.json();
|
||||
const pdfUrl =
|
||||
work?.primary_location?.pdf_url ??
|
||||
work?.best_oa_location?.pdf_url ??
|
||||
null;
|
||||
|
||||
const htmlUrl =
|
||||
work?.primary_location?.landing_page_url ??
|
||||
work?.best_oa_location?.landing_page_url ??
|
||||
work?.open_access?.oa_url ??
|
||||
null;
|
||||
|
||||
const resolvedUrl = pdfUrl || htmlUrl || fallbackUrl;
|
||||
this.publicationUrlCache.set(publicationId, resolvedUrl);
|
||||
return resolvedUrl;
|
||||
} catch {
|
||||
return fallbackUrl;
|
||||
}
|
||||
getPublicationUrl(publicationId: string): string {
|
||||
return this.selectedFunder?.publication_urls?.[publicationId] ?? publicationId;
|
||||
}
|
||||
|
||||
private getPublicationPageCountForFunder(funder: any): number {
|
||||
|
||||
Reference in New Issue
Block a user