Skip to content

Commit

Permalink
add 30 day filter
Browse files Browse the repository at this point in the history
  • Loading branch information
abhay authored and jthiller committed Sep 16, 2024
1 parent 4322a13 commit f2f1862
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/app/stats/utils/dune/fetchHntEmissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,21 @@ export const fetchHntEmissions = cache(async () => {
}
})

const totalEmissions = Object.keys(totalEmissionsCombined).map((date) => {
const { block_date, hnt_minted } = totalEmissionsCombined[date]
return {
block_date,
hnt_minted: Math.floor(hnt_minted),
}
})
const currentDate = new Date()
const thirtyDaysAgo = new Date()
thirtyDaysAgo.setDate(currentDate.getDate() - 30)

const totalEmissions = Object.keys(totalEmissionsCombined)
.map((date) => {
const { block_date, hnt_minted } = totalEmissionsCombined[date]
return {
block_date,
hnt_minted: Math.floor(hnt_minted),
}
})
.filter(({ block_date }) => {
return new Date(block_date) > thirtyDaysAgo
})

return {
totalEmissions,
Expand Down

0 comments on commit f2f1862

Please sign in to comment.