From 7269b4df437e35b88432be5b765d6086396ba8ce Mon Sep 17 00:00:00 2001 From: Futa Ikeda Date: Mon, 4 Nov 2024 15:54:04 -0500 Subject: [PATCH] Update metrics getter --- app/models/search-result.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/models/search-result.ts b/app/models/search-result.ts index 9cec3d98273..b092ac5573e 100644 --- a/app/models/search-result.ts +++ b/app/models/search-result.ts @@ -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, }; }