Skip to content

Commit

Permalink
Check last_time_logged to select correct record. Add same logic to la…
Browse files Browse the repository at this point in the history
…nding page as well.
  • Loading branch information
chuanlin2018 committed Jan 10, 2024
1 parent d9e6b02 commit 9cb10b3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
18 changes: 12 additions & 6 deletions angular/src/app/landing/landingpage.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { Themes, ThemesPrefs } from '../shared/globals/globals';
encapsulation: ViewEncapsulation.None
})
export class LandingPageComponent implements OnInit, AfterViewInit {
pdrid: string;
layoutCompact: boolean = true;
layoutMode: string = 'horizontal';
profileMode: string = 'inline';
Expand Down Expand Up @@ -223,6 +224,7 @@ export class LandingPageComponent implements OnInit, AfterViewInit {
metadataError = "not-found";
}
else{
this.pdrid = this.md["@id"];
this.theme = ThemesPrefs.getTheme((new NERDResource(this.md)).theme());

if(this.inBrowser){
Expand Down Expand Up @@ -310,12 +312,16 @@ export class LandingPageComponent implements OnInit, AfterViewInit {
}

if(hasFile){
//Now check if there is any metrics data
this.metricsData.totalDatasetDownload = this.recordLevelMetrics.DataSetMetrics[0] != undefined? this.recordLevelMetrics.DataSetMetrics[0].record_download : 0;

this.metricsData.totalDownloadSize = this.recordLevelMetrics.DataSetMetrics[0] != undefined? this.recordLevelMetrics.DataSetMetrics[0]["total_size_download"] : 0;

this.metricsData.totalUsers = this.recordLevelMetrics.DataSetMetrics[0] != undefined? this.recordLevelMetrics.DataSetMetrics[0].number_users : 0;
for(let metrics of this.recordLevelMetrics.DataSetMetrics) {
if((!this.pdrid || metrics["pdrid"].toLowerCase() == 'nan' || metrics["pdrid"].trim() == this.pdrid) && metrics["last_time_logged"]){
//Now check if there is any metrics data
this.metricsData.totalDatasetDownload = metrics != undefined? metrics.record_download : 0;

this.metricsData.totalDownloadSize = metrics != undefined? metrics["total_size_download"] : 0;

this.metricsData.totalUsers = metrics != undefined? metrics.number_users : 0;
}
}

this.metricsData.totalUsers = this.metricsData.totalUsers == undefined? 0 : this.metricsData.totalUsers;

Expand Down
3 changes: 1 addition & 2 deletions angular/src/app/metrics/metrics.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ export class MetricsComponent implements OnInit {
case HttpEventType.Response:
// this.recordLevelData = JSON.parse(JSON.stringify(event.body));
this.recordLevelData = JSON.parse(await event.body.text());

if(this.recordLevelData.DataSetMetrics != undefined && this.recordLevelData.DataSetMetrics.length > 0){

this.handleRecordLevelData();
Expand Down Expand Up @@ -254,7 +253,7 @@ export class MetricsComponent implements OnInit {
// this.recordLevelTotalDownloads = this.recordLevelData.DataSetMetrics[0].success_get;

for(let metrics of this.recordLevelData.DataSetMetrics) {
if(!this.pdrid || metrics["pdrid"].toLowerCase() == 'nan' || metrics["pdrid"].trim() == this.pdrid){
if((!this.pdrid || metrics["pdrid"].toLowerCase() == 'nan' || metrics["pdrid"].trim() == this.pdrid) && metrics["last_time_logged"]){
this.firstTimeLogged = this.datePipe.transform(metrics.first_time_logged, "MMM d, y");
this.recordLevelTotalDownloads = metrics.success_get;
this.totalDatasetDownloads = metrics.record_download;
Expand Down

0 comments on commit 9cb10b3

Please sign in to comment.