Skip to content

Commit

Permalink
Update metrics getter
Browse files Browse the repository at this point in the history
  • Loading branch information
futa-ikeda committed Nov 4, 2024
1 parent 52fc4f5 commit 7269b4d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/models/search-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,16 @@ export default class SearchResultModel extends Model {
}

get usageMetrics() {
if (!this.resourceMetadata.usage) {
return null;
}
const temporalCoverage = this.resourceMetadata.usage[0]['temporalCoverage'];
const viewCount = this.resourceMetadata.usage[0]['viewCount'];
const downloadCount = this.resourceMetadata.usage[0]['downloadCount'];
return {
period: this.resourceMetadata.usage[0]['temporalCoverage'][0]['@value'],
viewCount: this.resourceMetadata.usage[0]['viewCount'][0]['@value'],
downloadCount: this.resourceMetadata.usage[0]['downloadCount'][0]['@value'],
period: temporalCoverage ? temporalCoverage[0]['@value'] : null,
viewCount: viewCount ? viewCount[0]['@value'] : null,
downloadCount: downloadCount ? downloadCount[0]['@value'] : null,
};
}

Expand Down

0 comments on commit 7269b4d

Please sign in to comment.