Skip to content

Commit

Permalink
Fixed the calculation of total download size
Browse files Browse the repository at this point in the history
  • Loading branch information
chuanlin2018 committed Jan 8, 2024
1 parent 1e9373c commit 91f98f5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
11 changes: 4 additions & 7 deletions angular/src/app/landing/landingpage.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,6 @@ export class LandingPageComponent implements OnInit, AfterViewInit {

if (this.editRequested) {
showError = false;
// console.log("Returning from authentication redirection (editmode="+
// this.editRequested+")");

// Need to pass reqID (resID) because the resID in editControlComponent
// has not been set yet and the startEditing function relies on it.
this.edstatsvc.startEditing(this.reqId);
Expand Down Expand Up @@ -304,12 +301,12 @@ export class LandingPageComponent implements OnInit, AfterViewInit {
let hasFile = false;

if(this.md.components && this.md.components.length > 0){
this.md.components.forEach(element => {
if(element.filepath){
for(let com of this.md.components) {
if(com.filepath){
hasFile = true;
return;
break;
}
});
}
}

if(hasFile){
Expand Down
7 changes: 2 additions & 5 deletions angular/src/app/metrics/metrics.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,14 +515,11 @@ export class MetricsComponent implements OnInit {

/**
* Get total recordset level download size in bytes
* 01/08/2024 Discussed with Deoyani, use "total_size_download" in record level data.
* No need to add file level data anymore.
*/
get totalDownloadSizeInByte() {
let totalDownload = 0;
if(this.fileLevelData != undefined) {
this.fileLevelData.FilesMetrics.forEach( (file) => {
totalDownload += file.success_get * file.total_size_download;
});
}

if(this.recordLevelData != undefined) {
totalDownload += this.recordLevelData.DataSetMetrics[0]["total_size_download"];
Expand Down
17 changes: 12 additions & 5 deletions angular/src/app/shared/metrics-service/metrics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ export class MetricsService {
* @returns http response
*/
getFileLevelMetrics(ediid: string): Observable<any> {
let url = this.metricsBackend + "files?exclude=_id&include=ediid,filepath,success_get,download_size&ediid=" + ediid;

let url = this.metricsBackend + "files/" + ediid;
const request = new HttpRequest(
"GET", url,
{ headers: new HttpHeaders({ 'Content-Type': 'application/json', 'responseType': 'blob' }), reportProgress: true, responseType: 'blob' });
Expand Down Expand Up @@ -75,9 +74,17 @@ export class MetricsService {
}

for(let x of fileLevelData) {
if(x.pdrid.replace('ark:/88434/', '') == _pdrid.replace('ark:/88434/', '') && x.ediid.replace('ark:/88434/', '') == _ediid && (x.filepath? x.filepath.trim()==_filepath : false) && !x.filepath.endsWith('sha256')) {
ret = x;
break;
if(_pdrid.toLowerCase() == 'nan') {
if((x.filepath? x.filepath.trim()==_filepath : false) && x.ediid.replace('ark:/88434/', '') == _ediid && !x.filepath.endsWith('sha256')) {
ret = x;
break;
}
}else {
if(x.pdrid.replace('ark:/88434/', '') == _pdrid && x.ediid.replace('ark:/88434/', '') == _ediid && (x.filepath? x.filepath.trim()==_filepath : false) && !x.filepath.endsWith('sha256')) {
ret = x;
break;
}

}
}
}
Expand Down

0 comments on commit 91f98f5

Please sign in to comment.