generated frontend services and models

This commit is contained in:
Kazgatari
2026-07-03 22:33:32 +02:00
parent 47fb41105a
commit 1ddc5c42c5
13 changed files with 447 additions and 42 deletions
+1
View File
@@ -12,3 +12,4 @@ class Tags(StrEnum):
AUTH = "Auth"
ACCOUNT = "Account"
ORGANIZATION = "Organization"
UNIVERSITY_RANKINGS = "University Rankings"
@@ -20,7 +20,7 @@ logger = logging.getLogger(__name__)
router = APIRouter(
prefix="/api/inse-service/university-rankings",
tags=[Tags.INSTITUTIONS]
tags=[Tags.UNIVERSITY_RANKINGS]
)
@router.get(
+3
View File
@@ -26,6 +26,8 @@ export * from './topics.service';
import { TopicsService } from './topics.service';
export * from './works.service';
import { WorksService } from './works.service';
export * from './university-rankings.service';
import { UniversityRankingsService } from './university-rankings.service';
export const APIS = [
AuthService,
CompanyConnectionsService,
@@ -41,4 +43,5 @@ export const APIS = [
ProjectsService,
TopicsService,
WorksService,
UniversityRankingsService,
];
@@ -0,0 +1,344 @@
/**
* Innovation Search Engine API
*
* NOTE: This class is manually implemented to act as if it were auto-generated by OpenAPI Generator.
*/
/* tslint:disable:no-unused-variable member-ordering */
import { Inject, Injectable, Optional } from '@angular/core';
import {
HttpClient,
HttpHeaders,
HttpParams,
HttpResponse,
HttpEvent,
HttpParameterCodec,
HttpContext,
} from '@angular/common/http';
import { CustomHttpParameterCodec } from '../encoder';
import { Observable } from 'rxjs';
// @ts-ignore
import { RankingResponse } from '../model/rankingResponse';
// @ts-ignore
import { TrendResponse } from '../model/trendResponse';
// @ts-ignore
import { TopInstitutionItem } from '../model/topInstitutionItem';
// @ts-ignore
import { AutocompleteLocationItem } from '../model/autocompleteLocationItem';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
import { Configuration } from '../configuration';
import { BaseService } from '../api.base.service';
@Injectable({
providedIn: 'root',
})
export class UniversityRankingsService extends BaseService {
constructor(
protected httpClient: HttpClient,
@Optional() @Inject(BASE_PATH) basePath: string | string[],
@Optional() configuration?: Configuration,
) {
super(basePath, configuration);
}
public getRankingsApiInseServiceUniversityRankingsGet(
topic:
| 'Artificial Intelligence'
| 'Quantum Computing'
| 'Renewable Energy'
| 'Biotechnology',
metric?: 'publications' | 'citations',
observe: any = 'body',
reportProgress: boolean = false,
options?: {
httpHeaderAccept?: 'application/json';
context?: HttpContext;
transferCache?: boolean;
},
): Observable<any> {
if (topic === null || topic === undefined) {
throw new Error(
'Required parameter topic was null or undefined when calling getRankingsApiInseServiceUniversityRankingsGet.',
);
}
let localVarQueryParameters = new HttpParams({ encoder: this.encoder });
localVarQueryParameters = this.addToHttpParams(
localVarQueryParameters,
<any>topic,
'topic',
);
localVarQueryParameters = this.addToHttpParams(
localVarQueryParameters,
<any>metric,
'metric',
);
let localVarHeaders = this.defaultHeaders;
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';
let localVarPath = `/api/inse-service/university-rankings`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<RankingResponse>(
'get',
`${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined
? { transferCache: localVarTransferCache }
: {}),
reportProgress: reportProgress,
},
);
}
public getTrendApiInseServiceUniversityRankingsTrendGet(
topics: string[],
institutions?: string[],
countries?: string[],
regions?: string[],
observe: any = 'body',
reportProgress: boolean = false,
options?: {
httpHeaderAccept?: 'application/json';
context?: HttpContext;
transferCache?: boolean;
},
): Observable<any> {
if (topics === null || topics === undefined) {
throw new Error(
'Required parameter topics was null or undefined when calling getTrendApiInseServiceUniversityRankingsTrendGet.',
);
}
let localVarQueryParameters = new HttpParams({ encoder: this.encoder });
if (topics) {
topics.forEach((val) => {
localVarQueryParameters = this.addToHttpParams(
localVarQueryParameters,
<any>val,
'topics',
);
});
}
if (institutions) {
institutions.forEach((val) => {
localVarQueryParameters = this.addToHttpParams(
localVarQueryParameters,
<any>val,
'institutions',
);
});
}
if (countries) {
countries.forEach((val) => {
localVarQueryParameters = this.addToHttpParams(
localVarQueryParameters,
<any>val,
'countries',
);
});
}
if (regions) {
regions.forEach((val) => {
localVarQueryParameters = this.addToHttpParams(
localVarQueryParameters,
<any>val,
'regions',
);
});
}
let localVarHeaders = this.defaultHeaders;
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';
let localVarPath = `/api/inse-service/university-rankings/trend`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<TrendResponse>(
'get',
`${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined
? { transferCache: localVarTransferCache }
: {}),
reportProgress: reportProgress,
},
);
}
public getTopInstitutionsApiInseServiceUniversityRankingsTopInstitutionsGet(
topic: string,
region?: string,
country?: string,
limit?: number,
observe: any = 'body',
reportProgress: boolean = false,
options?: {
httpHeaderAccept?: 'application/json';
context?: HttpContext;
transferCache?: boolean;
},
): Observable<any> {
if (topic === null || topic === undefined) {
throw new Error(
'Required parameter topic was null or undefined when calling getTopInstitutionsApiInseServiceUniversityRankingsTopInstitutionsGet.',
);
}
let localVarQueryParameters = new HttpParams({ encoder: this.encoder });
localVarQueryParameters = this.addToHttpParams(
localVarQueryParameters,
<any>topic,
'topic',
);
localVarQueryParameters = this.addToHttpParams(
localVarQueryParameters,
<any>region,
'region',
);
localVarQueryParameters = this.addToHttpParams(
localVarQueryParameters,
<any>country,
'country',
);
localVarQueryParameters = this.addToHttpParams(
localVarQueryParameters,
<any>limit,
'limit',
);
let localVarHeaders = this.defaultHeaders;
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';
let localVarPath = `/api/inse-service/university-rankings/top-institutions`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<Array<TopInstitutionItem>>(
'get',
`${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined
? { transferCache: localVarTransferCache }
: {}),
reportProgress: reportProgress,
},
);
}
public getAutocompleteLocationsApiInseServiceUniversityRankingsAutocompleteLocationsGet(
query: string,
observe: any = 'body',
reportProgress: boolean = false,
options?: {
httpHeaderAccept?: 'application/json';
context?: HttpContext;
transferCache?: boolean;
},
): Observable<any> {
if (query === null || query === undefined) {
throw new Error(
'Required parameter query was null or undefined when calling getAutocompleteLocationsApiInseServiceUniversityRankingsAutocompleteLocationsGet.',
);
}
let localVarQueryParameters = new HttpParams({ encoder: this.encoder });
localVarQueryParameters = this.addToHttpParams(
localVarQueryParameters,
<any>query,
'query',
);
let localVarHeaders = this.defaultHeaders;
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';
let localVarPath = `/api/inse-service/university-rankings/autocomplete-locations`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<Array<AutocompleteLocationItem>>(
'get',
`${basePath}${localVarPath}`,
{
context: localVarHttpContext,
params: localVarQueryParameters,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined
? { transferCache: localVarTransferCache }
: {}),
reportProgress: reportProgress,
},
);
}
}
@@ -0,0 +1,6 @@
export interface AutocompleteLocationItem {
id: string;
display_name: string;
code: string;
type: 'country' | 'continent';
}
+3
View File
@@ -177,3 +177,6 @@ export * from './workTopicSubfield';
export * from './worksFilterProperties';
export * from './worksListResponse';
export * from './yearlyData';
export * from './trendResponse';
export * from './topInstitutionItem';
export * from './autocompleteLocationItem';
@@ -0,0 +1,7 @@
import { DehydratedInstitution } from './dehydratedInstitution';
export interface TopInstitutionItem extends DehydratedInstitution {
works_count?: number | null;
image_thumbnail_url?: string | null;
exact_topic_count?: number | null;
}
+20
View File
@@ -0,0 +1,20 @@
export interface TopicYearlyData {
year: number;
raw: number;
normalized: number;
institutions_count: number;
}
export interface TrendSeries {
entity_id: string;
entity_name: string;
entity_type: 'institution' | 'country' | 'region';
country_code?: string | null;
topic_data: { [key: string]: Array<TopicYearlyData> };
}
export interface TrendResponse {
series: Array<TrendSeries>;
years: Array<number>;
location_mappings?: { [key: string]: Array<string> } | null;
}
@@ -229,5 +229,13 @@
Suchen
</button>
</div>
<!-- Trend Comparison Section -->
@if (selectedKeywords().length > 0) {
<div style="margin-top: 2rem">
<app-uni-trend-parent
[keywords]="selectedKeywords()"></app-uni-trend-parent>
</div>
}
</div>
</div>
@@ -28,6 +28,7 @@ import { TopicsService } from '../../api/api/topics.service';
import { KeywordsTopicsRequest } from '../../api/model/keywordsTopicsRequest';
import { KeywordEntryWithTopic } from '../../api/model/keywordEntryWithTopic';
import { TopicAutocompleteComponent } from '../../shared/ui/topic-autocomplete/topic-autocomplete.component';
import { UniTrendParentComponent } from '../university-ranking/uni-trend-parent/uni-trend-parent.component';
type InputMode = 'url' | 'text';
type KeywordCategory = 'broad' | 'coarse' | 'fine' | 'manual';
@@ -47,6 +48,7 @@ type KeywordCategory = 'broad' | 'coarse' | 'fine' | 'manual';
MatExpansionModule,
MatProgressBarModule,
TopicAutocompleteComponent,
UniTrendParentComponent,
],
templateUrl: './keywords-search.component.html',
styleUrl: './keywords-search.component.scss',
@@ -3,6 +3,7 @@ import { inject, Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import {
InstitutionsService,
UniversityRankingsService,
RankingResponse,
TrendResponse,
TopInstitutionItem,
@@ -20,6 +21,7 @@ export type DashboardMetric = 'publications' | 'citations';
@Injectable({ providedIn: 'root' })
export class UniversityRankingService {
private apiService = inject(InstitutionsService);
private rankingsApiService = inject(UniversityRankingsService);
/**
* Fetches ranking and timeseries data directly from the backend.
@@ -29,7 +31,7 @@ export class UniversityRankingService {
topic: ResearchTopic,
metric: DashboardMetric,
): Observable<RankingResponse> {
return this.apiService.getRankingsApiInseServiceUniversityRankingsGet(
return this.rankingsApiService.getRankingsApiInseServiceUniversityRankingsGet(
topic,
metric,
);
@@ -45,7 +47,7 @@ export class UniversityRankingService {
countries?: string[],
regions?: string[],
): Observable<TrendResponse> {
return this.apiService.getTrendApiInseServiceUniversityRankingsTrendGet(
return this.rankingsApiService.getTrendApiInseServiceUniversityRankingsTrendGet(
topics as any,
institutions,
countries,
@@ -62,7 +64,7 @@ export class UniversityRankingService {
country?: string,
limit?: number,
): Observable<TopInstitutionItem[]> {
return this.apiService.getTopInstitutionsApiInseServiceUniversityRankingsTopInstitutionsGet(
return this.rankingsApiService.getTopInstitutionsApiInseServiceUniversityRankingsTopInstitutionsGet(
topic,
region,
country,
@@ -86,7 +88,7 @@ export class UniversityRankingService {
* Autocompletes countries and continents.
*/
autocompleteLocations(query: string): Observable<AutocompleteLocationItem[]> {
return this.apiService.getAutocompleteLocationsApiInseServiceUniversityRankingsAutocompleteLocationsGet(
return this.rankingsApiService.getAutocompleteLocationsApiInseServiceUniversityRankingsAutocompleteLocationsGet(
query,
);
}
@@ -6,7 +6,7 @@ import {
} from '@angular/core';
import { EChartsOption } from 'echarts';
import { NgxEchartsDirective } from 'ngx-echarts';
import { TrendResponse } from '../../../api';
import { TrendResponse, TrendSeries, TopicYearlyData } from '../../../api';
@Component({
selector: 'app-uni-trend-chart',
@@ -162,10 +162,10 @@ export class UniTrendChartComponent {
},
tooltip: {
trigger: 'axis',
axisPointer: { type: 'cross' },
backgroundColor: 'rgba(255, 255, 255, 0.95)',
backgroundColor: 'rgba(255, 255, 255, 0.96)',
borderColor: '#e5e7eb',
borderWidth: 1,
padding: 0,
textStyle: {
color: '#374151',
fontSize: 12,
@@ -178,14 +178,14 @@ export class UniTrendChartComponent {
res += `<strong style="font-size: 13px; color: #111827;">Year: ${yearNum}</strong><br/>`;
res += `<hr style="border: 0; border-top: 1px solid #e5e7eb; margin: 4px 0 8px 0;"/>`;
trendData.series.forEach((entity, entityIdx) => {
trendData.series.forEach((entity: TrendSeries, entityIdx: number) => {
const color = entityColors[entityIdx % entityColors.length];
res += `<div style="margin-bottom: 6px;">`;
res += `<span style="display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background-color:${color};"></span>`;
res += `<strong style="color: #374151;">${entity.entity_name}</strong>:<br/>`;
const yrData = entity.topic_data[selectedTopic]?.find(
(y) => y.year === yearNum,
(y: TopicYearlyData) => y.year === yearNum,
);
if (yrData) {
const val =
@@ -201,24 +201,26 @@ export class UniTrendChartComponent {
const instCountryCode = entity.country_code?.toUpperCase();
const parentCountry = trendData.series.find(
(s) =>
(s: TrendSeries) =>
s.entity_type === 'country' &&
s.entity_id.toUpperCase() === instCountryCode,
);
const parentContinent = trendData.series.find((s) => {
if (s.entity_type !== 'region') return false;
const memberCountries =
trendData.location_mappings?.[s.entity_id] || [];
return memberCountries.some(
(c) => c.toUpperCase() === instCountryCode,
);
});
const parentContinent = trendData.series.find(
(s: TrendSeries) => {
if (s.entity_type !== 'region') return false;
const memberCountries =
trendData.location_mappings?.[s.entity_id] || [];
return memberCountries.some(
(c: string) => c.toUpperCase() === instCountryCode,
);
},
);
if (parentCountry) {
const parentYr = parentCountry.topic_data[
selectedTopic
]?.find((y) => y.year === yearNum);
]?.find((y: TopicYearlyData) => y.year === yearNum);
if (parentYr && parentYr.raw > 0) {
const pct = (yrData.raw / parentYr.raw) * 100;
contributionStr = ` (${pct.toFixed(1)}% of ${parentCountry.entity_name})`;
@@ -226,17 +228,19 @@ export class UniTrendChartComponent {
} else if (parentContinent) {
const parentYr = parentContinent.topic_data[
selectedTopic
]?.find((y) => y.year === yearNum);
]?.find((y: TopicYearlyData) => y.year === yearNum);
if (parentYr && parentYr.raw > 0) {
const pct = (yrData.raw / parentYr.raw) * 100;
contributionStr = ` (${pct.toFixed(1)}% of ${parentContinent.entity_name})`;
}
} else {
const sumInsts = trendData.series
.filter((s) => s.entity_type === 'institution')
.reduce((sum, s) => {
.filter(
(s: TrendSeries) => s.entity_type === 'institution',
)
.reduce((sum: number, s: TrendSeries) => {
const y = s.topic_data[selectedTopic]?.find(
(yd) => yd.year === yearNum,
(yd: TopicYearlyData) => yd.year === yearNum,
);
return sum + (y ? y.raw : 0);
}, 0);
@@ -248,24 +252,26 @@ export class UniTrendChartComponent {
} else if (entity.entity_type === 'country') {
const countryCode = entity.entity_id.toUpperCase();
const parentContinent = trendData.series.find((s) => {
if (s.entity_type !== 'region') return false;
const memberCountries =
trendData.location_mappings?.[s.entity_id] || [];
return memberCountries.some(
(c) => c.toUpperCase() === countryCode,
);
});
const parentContinent = trendData.series.find(
(s: TrendSeries) => {
if (s.entity_type !== 'region') return false;
const memberCountries =
trendData.location_mappings?.[s.entity_id] || [];
return memberCountries.some(
(c: string) => c.toUpperCase() === countryCode,
);
},
);
const childInstsSum = trendData.series
.filter(
(s) =>
(s: TrendSeries) =>
s.entity_type === 'institution' &&
s.country_code?.toUpperCase() === countryCode,
)
.reduce((sum, s) => {
.reduce((sum: number, s: TrendSeries) => {
const y = s.topic_data[selectedTopic]?.find(
(yd) => yd.year === yearNum,
(yd: TopicYearlyData) => yd.year === yearNum,
);
return sum + (y ? y.raw : 0);
}, 0);
@@ -276,7 +282,7 @@ export class UniTrendChartComponent {
if (parentContinent) {
const parentYr = parentContinent.topic_data[
selectedTopic
]?.find((y) => y.year === yearNum);
]?.find((y: TopicYearlyData) => y.year === yearNum);
if (parentYr && parentYr.raw > 0) {
const pct = (yrData.raw / parentYr.raw) * 100;
contributionStr = ` (${pct.toFixed(1)}% of ${parentContinent.entity_name})`;
@@ -292,23 +298,24 @@ export class UniTrendChartComponent {
trendData.location_mappings?.[continentId] || [];
const childSum = trendData.series
.filter((s) => {
.filter((s: TrendSeries) => {
if (s.entity_type === 'country') {
return memberCountries.some(
(c) => c.toUpperCase() === s.entity_id.toUpperCase(),
(c: string) =>
c.toUpperCase() === s.entity_id.toUpperCase(),
);
}
if (s.entity_type === 'institution') {
return memberCountries.some(
(c) =>
(c: string) =>
c.toUpperCase() === s.country_code?.toUpperCase(),
);
}
return false;
})
.reduce((sum, s) => {
.reduce((sum: number, s: TrendSeries) => {
const y = s.topic_data[selectedTopic]?.find(
(yd) => yd.year === yearNum,
(yd: TopicYearlyData) => yd.year === yearNum,
);
return sum + (y ? y.raw : 0);
}, 0);
@@ -16,6 +16,8 @@ import { UniversityRankingsService } from '../../../api/api/university-rankings.
import { InstitutionsService } from '../../../api/api/institutions.service';
import {
TrendResponse,
TrendSeries,
TopicYearlyData,
TopInstitutionItem,
AutocompleteLocationItem,
AutocompleteResponse,
@@ -89,7 +91,7 @@ export class UniTrendParentComponent implements OnInit {
);
const defaultInstId = 'https://openalex.org/I62318514'.toLowerCase();
const filteredSeries = raw.series.filter((s: any) => {
const filteredSeries = raw.series.filter((s: TrendSeries) => {
const id = s.entity_id.toLowerCase();
if (s.entity_type === 'institution') {
return id === defaultInstId || currentInstIds.has(id);