diff --git a/landingPages/dataProvider/dataProvider.component.ts b/landingPages/dataProvider/dataProvider.component.ts index 3cc5bd2b..0d9cc2d7 100644 --- a/landingPages/dataProvider/dataProvider.component.ts +++ b/landingPages/dataProvider/dataProvider.component.ts @@ -247,7 +247,6 @@ export class DataProviderComponent { } }); } - this.getMetrics(); })); } @@ -408,6 +407,11 @@ export class DataProviderComponent { } this.showLoading = false; + + // ensure that if the API call to index does not have metrics, we get them from old metrics service call + if(this.dataProviderInfo && !this.dataProviderInfo.measure) { + this.getMetrics(); + } this.cdr.detectChanges(); // if (this.dataProviderInfo.tabs != undefined && this.dataProviderInfo.tabs.length > 0) { @@ -715,9 +719,12 @@ export class DataProviderComponent { obs = zip(this.metricsService.getMetricsNumber(this.datasourceId, "usagestats.views.repository.local", this.properties), this.metricsService.getMetricsNumber(this.datasourceId, "usagestats.downloads.repository.local", this.properties)); this.sub = obs.subscribe(data => { - this.totalViews = data[0]; - this.totalDownloads = data[1]; - this.cdr.detectChanges(); + if(data[0] && data[1] && data[0] > 0 && data[1] > 0) { + this.dataProviderInfo.measure = {counts: []}; + this.dataProviderInfo.measure.counts.push({name: 'views', order: 0, icon: 'visibility', value: data[0]}); + this.dataProviderInfo.measure.counts.push({name: 'downloads', order: 1, icon: 'downloads', value: data[1]}); + this.cdr.detectChanges(); + } }); } diff --git a/landingPages/project/project.component.ts b/landingPages/project/project.component.ts index 91e93f9a..c420a552 100644 --- a/landingPages/project/project.component.ts +++ b/landingPages/project/project.component.ts @@ -264,8 +264,6 @@ export class ProjectComponent { this.downloadURLAPI = this.properties.csvAPIURL; this.createClipboard(); - - this.getMetrics(); })); } @@ -535,6 +533,11 @@ export class ProjectComponent { startDate: this.projectInfo.startDate, endDate: this.projectInfo.endDate }; + + // ensure that if the API call to index does not have metrics, we get them from old metrics service call + if(this.projectInfo && !this.projectInfo.measure) { + this.getMetrics(); + } //old // this.viewsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"projRepoViews","projTitle":"' + this.projectId + '","table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":"","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[]}]&info_types=["column"]&stacking=&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(124, 181, 236, 1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; // @@ -600,9 +603,14 @@ export class ProjectComponent { obs = zip(this.metricsService.getMetricsNumber(this.projectId, "usagestats.projects.views", this.properties), this.metricsService.getMetricsNumber(this.projectId, "usagestats.projects.downloads", this.properties)); this.sub = obs.subscribe(data => { - this.totalViews = data[0]; - this.totalDownloads = data[1]; - this.cdr.detectChanges(); + if(data[0] && data[1] && data[0] > 0 && data[1] > 0) { + this.projectInfo.measure = {counts: []}; + this.projectInfo.measure.counts.push({name: 'views', order: 0, icon: 'visibility', value: data[0]}); + this.projectInfo.measure.counts.push({name: 'downloads', order: 1, icon: 'downloads', value: data[1]}); + this.cdr.detectChanges(); + } + // this.totalViews = data[0]; + // this.totalDownloads = data[1]; }); }