remove unused methods from metrics Service, remove metricsAPIURL property

This commit is contained in:
argirok 2022-06-08 14:39:05 +03:00
parent 6ba20cd2bb
commit fbb86407c4
2 changed files with 1 additions and 65 deletions

View File

@ -81,68 +81,5 @@ export class MetricsService {
return map;
}
getMetrics (id: string, entityType: string, properties:EnvProperties):any {
let url = properties.metricsAPIURL+entityType+"/"+id+"/clicks";
let key = url;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.pipe(map(res => this.parseMetrics(res["downloads"], res["views"], res["total_downloads"], res["total_views"],
res["total_openaire_views"], res["total_openaire_downloads"], res["pageviews"], properties)));
}
parseMetrics(downloads: any, views: any, totalDownloads: number, totalViews: number,
totalOpenaireViews: number, totalOpenaireDownloads: number, pageViews: number, properties:EnvProperties): any {
this.metrics = new Metrics();
this.metrics.totalDownloads = totalDownloads;
this.metrics.totalViews = totalViews;
this.metrics.totalOpenaireViews = totalOpenaireViews;
this.metrics.totalOpenaireDownloads = totalOpenaireDownloads;
this.metrics.pageViews = pageViews;
this.metrics.infos = new Map<string, {"name": string, "url": string, "numOfDownloads": string, "numOfViews": string, "openaireDownloads": string, "openaireViews": string}>();
for(let i=0; i<downloads.length; i++) {
let id: string = downloads[i]['datasource_id'];
if(this.metrics.infos.has(id)) {
this.metrics.infos.get(id).numOfDownloads = downloads[i]['value'];
this.metrics.infos.get(id).openaireDownloads = downloads[i]['openaire'];
} else {
let info;//: {"url": string, "numOfDownloads": string, "numOfViews": string};
info = {};
info.name = downloads[i]['datasource_name'];
info.url = properties.searchLinkToDataProvider+id;
info.numOfDownloads = downloads[i]['value'];
info.openaireDownloads = downloads[i]['openaire'];
info.numOfViews = "0";
info.openaireViews = "0";
this.metrics.infos.set(id, info);
}
}
for(let i=0; i<views.length; i++) {
let id: string = views[i]['datasource_id'];
if(this.metrics.infos.has(id)) {
this.metrics.infos.get(id).numOfViews = views[i]['value'];
this.metrics.infos.get(id).openaireViews = views[i]['openaire'];
} else {
let info;//: {"url": string, "numOfDownloads": string, "numOfViews": string};
info = {};
info.name = views[i]['datasource_name'];
info.url = properties.searchLinkToDataProvider + id;
info.numOfDownloads = "0";
info.openaireDownloads = "0";
info.numOfViews = views[i]['value'];
info.openaireViews = views[i]['openaire'];
this.metrics.infos.set(id, info);
}
}
return this.metrics;
}
}

View File

@ -14,7 +14,6 @@ export interface EnvProperties {
showAddThis?: boolean;
showContent?: boolean;
enableEoscDataTransfer?:boolean;
metricsAPIURL?: string;
framesAPIURL?: string;
statisticsFrameAPIURL?: string;
statisticsFrameNewAPIURL?: string;