Skip to content

Commit

Permalink
feat: transaction trend in the last 24 hours (#673)
Browse files Browse the repository at this point in the history
  • Loading branch information
janmichek committed Mar 12, 2024
1 parent 432dd45 commit 8a0f329
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/TransactionsStatistics.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<h5>TRANSACTIONS IN LAST 24H</h5>
<div class="transaction-statistics__value">
{{ formatNumber(last24hsTransactionsCount) }}
<app-chip :variant="chipVariant">
{{ last24hsTransactionsTrend }} %
</app-chip>
</div>
</app-panel>
</div>
Expand All @@ -24,11 +27,13 @@ const { fetchTotalTransactionsCount } = useBlockchainStatsStore()
const { fetchLast24hsTransactionsCount } = useTransactionsStore()
const { transactionsCount } = storeToRefs(useBlockchainStatsStore())
const { last24hsTransactionsCount } = storeToRefs(useTransactionsStore())
const { last24hsTransactionsCount, last24hsTransactionsTrend } = storeToRefs(useTransactionsStore())
await fetchTotalTransactionsCount()
await fetchLast24hsTransactionsCount()
const chipVariant = computed(() => last24hsTransactionsTrend.value > 0 ? 'success' : 'error')
</script>

<style scoped>
Expand Down
5 changes: 5 additions & 0 deletions src/stores/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const useTransactionsStore = defineStore('transactions', () => {
const transactionsCount = ref(null)
const transactionsStatistics = ref(null)
const last24hsTransactionsCount = ref(null)
const last24hsTransactionsTrend = ref(null)

const transactions = computed(() =>
rawTransactions.value
Expand All @@ -35,6 +36,9 @@ export const useTransactionsStore = defineStore('transactions', () => {
last24hsTransactionsCount.value = null
const { data } = await axios.get(`${MIDDLEWARE_URL}/v2/stats`)
last24hsTransactionsCount.value = data.last24hsTransactions
last24hsTransactionsTrend.value = data.last24hsTransactions !== 0
? formatNumber((100 * data.transactionsTrend / data.last24hsTransactions), 0, 2)
: '---'
}

async function fetchTransactionsStatistics(interval = 'day', limit = 7, range) {
Expand All @@ -59,5 +63,6 @@ export const useTransactionsStore = defineStore('transactions', () => {
fetchTransactionsStatistics,
fetchLast24hsTransactionsCount,
last24hsTransactionsCount,
last24hsTransactionsTrend,
}
})

0 comments on commit 8a0f329

Please sign in to comment.