load research timeline via generated works API
LocationBasedServices/smartguide/pipeline/head This commit looks good

This commit is contained in:
2026-06-04 15:42:36 +02:00
parent 9dd47f4373
commit 97db19f042
8 changed files with 178 additions and 12 deletions
@@ -53,6 +53,9 @@ model/models.ts
model/openAccess.ts
model/personBio.ts
model/score.ts
model/topicCount.ts
model/topicsByTime.ts
model/topicsByYear.ts
model/validationError.ts
model/validationErrorLocInner.ts
model/value.ts
+66
View File
@@ -19,6 +19,8 @@ import { Observable } from 'rxjs';
// @ts-ignore
import { HTTPValidationError } from '../model/hTTPValidationError';
// @ts-ignore
import { TopicsByTime } from '../model/topicsByTime';
// @ts-ignore
import { WorkPage } from '../model/workPage';
// @ts-ignore
import { WorksListResponse } from '../model/worksListResponse';
@@ -185,4 +187,68 @@ export class WorksService extends BaseService {
);
}
/**
* Returns topics grouped by publication year for an author.
* @endpoint get /api/works/{author_id}/topics-by-time
* @param authorId The author id, for example A5023888391.
* @param maxTopicsPerYear The maximum number of topics per year.
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getTopicsByTimeByAuthor(authorId: string, maxTopicsPerYear?: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<TopicsByTime>;
public getTopicsByTimeByAuthor(authorId: string, maxTopicsPerYear?: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<TopicsByTime>>;
public getTopicsByTimeByAuthor(authorId: string, maxTopicsPerYear?: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<TopicsByTime>>;
public getTopicsByTimeByAuthor(authorId: string, maxTopicsPerYear?: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
if (authorId === null || authorId === undefined) {
throw new Error('Required parameter authorId was null or undefined when calling getTopicsByTimeByAuthor.');
}
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>maxTopicsPerYear, 'max_topics_per_year');
let localVarHeaders = this.defaultHeaders;
// authentication (bearer) required
localVarHeaders = this.configuration.addCredentialToHeaders('bearer', 'Authorization', localVarHeaders, 'Bearer ');
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
'application/json'
]);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
}
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/api/works/${this.configuration.encodeParam({name: "authorId", value: authorId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}/topics-by-time`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<TopicsByTime>('get', `${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
reportProgress: reportProgress
}
);
}
}
+3
View File
@@ -35,6 +35,9 @@ export * from './model2YrMeanCitedness';
export * from './openAccess';
export * from './personBio';
export * from './score';
export * from './topicCount';
export * from './topicsByTime';
export * from './topicsByYear';
export * from './validationError';
export * from './validationErrorLocInner';
export * from './value';
+22
View File
@@ -0,0 +1,22 @@
/**
* Innovation Search Engine API
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export interface TopicCount {
/**
* The topic display name.
*/
name: string;
/**
* The number of occurrences.
*/
count?: number;
}
+23
View File
@@ -0,0 +1,23 @@
/**
* Innovation Search Engine API
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { TopicsByYear } from './topicsByYear';
export interface TopicsByTime {
/**
* Topics grouped by year.
*/
elements?: Array<TopicsByYear>;
/**
* The number of years.
*/
total?: number;
}
+31
View File
@@ -0,0 +1,31 @@
/**
* Innovation Search Engine API
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { TopicCount } from './topicCount';
export interface TopicsByYear {
/**
* The publication year.
*/
year: number;
/**
* The number of works in this year.
*/
publication_count?: number;
/**
* The topics in this year.
*/
topics?: Array<TopicCount>;
/**
* The primary topics in this year.
*/
primary_topics?: Array<TopicCount>;
}
@@ -1,20 +1,16 @@
import { CommonModule } from '@angular/common';
import { HttpClient } from '@angular/common/http';
import { Component, DestroyRef, OnInit, inject } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ActivatedRoute, ParamMap } from '@angular/router';
import { combineLatest, distinctUntilChanged, map } from 'rxjs';
import { TopicCount, TopicsByYear, WorksService } from '../../api';
import {
ResearchTimelineComponent,
TopicTimelineElement,
TopicTimelineTopic,
} from './components/research-timeline/research-timeline.component';
interface TopicTimelineResponse {
elements: TopicTimelineElement[];
total: number;
}
@Component({
selector: 'app-person-overview',
standalone: true,
@@ -24,7 +20,7 @@ interface TopicTimelineResponse {
})
export class PersonOverviewComponent implements OnInit {
private readonly route = inject(ActivatedRoute);
private readonly http = inject(HttpClient);
private readonly worksService = inject(WorksService);
private readonly destroyRef = inject(DestroyRef);
topicTimelineElements: TopicTimelineElement[] = [];
@@ -63,14 +59,13 @@ export class PersonOverviewComponent implements OnInit {
this.timelineLoadFailed = false;
const topicCountLimit = 4;
const url = `/inse-service/authors/${encodeURIComponent(authorId)}/topics-by-time?max_topics_per_year=${topicCountLimit}`;
this.http
.get<TopicTimelineResponse>(url)
this.worksService
.getTopicsByTimeByAuthor(authorId, topicCountLimit)
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({
next: (response) => {
this.topicTimelineElements = response.elements ?? [];
this.topicTimelineElements = this.mapTimelineElements(response.elements);
this.loadingTimeline = false;
this.timelineLoadFailed = false;
},
@@ -82,4 +77,22 @@ export class PersonOverviewComponent implements OnInit {
},
});
}
}
private mapTimelineElements(
elements: TopicsByYear[] | undefined,
): TopicTimelineElement[] {
return (elements ?? []).map((element) => ({
year: element.year,
publication_count: element.publication_count ?? 0,
topics: this.mapTopicCounts(element.topics),
primary_topics: this.mapTopicCounts(element.primary_topics),
}));
}
private mapTopicCounts(topics: TopicCount[] | undefined): TopicTimelineTopic[] {
return (topics ?? []).map((topic) => ({
name: topic.name,
count: topic.count ?? 0,
}));
}
}
+5
View File
@@ -4,6 +4,11 @@
"secure": false,
"changeOrigin": true
},
"/api/": {
"target": "http://127.0.0.1:8000",
"secure": false,
"changeOrigin": true
},
"/inse-account/": {
"target": "http://127.0.0.1:8000",
"secure": false,