Skip to content

Commit

Permalink
Merge pull request #808 from ignapas/metrics-date
Browse files Browse the repository at this point in the history
Metrics date to old project
  • Loading branch information
egauzens authored Jun 15, 2024
2 parents 4b1f122 + 082a859 commit 0ca1c33
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pages/about/metrics/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
:is="metricsComponent"
:metrics-data="metricsData"
/>
<div class="row my-32">
Last metrics update: {{ monthLastUpdate.toLocaleString('default', { month: 'long' }) }} {{ monthLastUpdate.getFullYear() }}
</div>
</div>
</div>
</template>
Expand Down Expand Up @@ -149,16 +152,20 @@ export default {
// we use last months date to get the metrics bc the metrics for the current month aren't published until the end of the month
const lastMonthsDate = getPreviousDate(currentMonth, currentYear)
let metricsData = undefined
let monthLastUpdate
try {
metricsData = await fetchMetrics($axios, lastMonthsDate.month, lastMonthsDate.year)
monthLastUpdate = new Date(`${lastMonthsDate.month}/01/${lastMonthsDate.year}`)
} catch (e) {
const monthBeforeLastDate = getPreviousDate(lastMonthsDate.month, lastMonthsDate.year)
metricsData = await fetchMetrics($axios, monthBeforeLastDate.month, monthBeforeLastDate.year).catch(() => {
error({ statusCode: 400, message: ErrorMessages.methods.metrics(), display: true, error: e } )
})
monthLastUpdate = new Date(`${monthBeforeLastDate.month}/01/${monthBeforeLastDate.year}`)
}
return {
metricsData
metricsData,
monthLastUpdate
}
},
Expand Down

0 comments on commit 0ca1c33

Please sign in to comment.