Skip to content

Commit 3449720

Browse files
committed
use data from mdw to chart
1 parent d898410 commit 3449720

File tree

4 files changed

+33
-26
lines changed

4 files changed

+33
-26
lines changed

src/components/MinersStatistics.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@
131131
{{ miningHints.mining }}
132132
</hint-tooltip>
133133
</h2>
134-
<pie-chart/>
134+
135+
<pie-chart :top-miners="topMiners"/>
135136
<!-- todo chart abstraction-->
136137
<!-- todo add legend-->
137138
</app-panel>
@@ -142,17 +143,19 @@ import { miningHints } from '@/utils/hints/miningHints'
142143
import { useMinersStore } from '@/composables/miners'
143144
import { formatAettosToAe } from '@/utils/format'
144145
145-
const { fetchMining } = useMinersStore()
146+
const { fetchMining, fetchTopMiners } = useMinersStore()
146147
const {
147148
minersCount,
148149
blockReward,
149150
status,
150151
blocksPerMinute,
151152
maxTPS,
153+
topMiners,
152154
} = storeToRefs(useMinersStore())
153155
154156
if (process.client) {
155157
await fetchMining()
158+
await fetchTopMiners()
156159
}
157160
</script>
158161

src/components/PieChart.vue

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,32 @@ import {
2424
Tooltip,
2525
} from 'chart.js'
2626
import { Doughnut } from 'vue-chartjs'
27+
import { formatKnownAddress } from '~/utils/format'
2728
28-
// const hasChart = computed(() => props.data?.length > 0)
2929
const isEmpty = computed(() => props.data?.length === 0)
3030
const isLoading = computed(() => props.data === null)
3131
3232
const props = defineProps({
33-
// data: {
34-
// type: Array,
35-
// default: null,
36-
// },
3733
interval: {
3834
type: String,
3935
required: true,
4036
},
37+
topMiners: {
38+
type: Array,
39+
required: true,
40+
},
41+
})
42+
const stats = computed(() => {
43+
return props.topMiners.map(item => item.blocksMined)
44+
})
45+
const legend = computed(() => {
46+
return props.topMiners.map(item => formatKnownAddress(item.miner))
4147
})
4248
const data = {
43-
labels: [
44-
'2miners',
45-
'2miners.solo',
46-
'WoolyPooly',
47-
],
49+
labels: legend.value,
4850
datasets: [{
4951
label: 'My First Dataset',
50-
data: [48, 2, 50],
52+
data: stats.value,
5153
backgroundColor: [
5254
'rgb(255, 99, 132)',
5355
'rgb(54, 162, 235)',
@@ -57,11 +59,6 @@ const data = {
5759
}],
5860
}
5961
60-
// const stats = computed(() => {
61-
// return props.data.map(stat => {
62-
// return stat.count
63-
// })
64-
// })
6562
//
6663
// const labels = computed(() => {
6764
// return props.data.map(stat => {

src/composables/miners.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const useMinersStore = defineStore('miners', () => {
1414
const status = ref(null)
1515
const maxTPS = ref(null)
1616
const blocksPerMinute = ref(null)
17+
const topMiners = ref(null)
1718

1819
function fetchMining() {
1920
return Promise.all([
@@ -27,30 +28,37 @@ export const useMinersStore = defineStore('miners', () => {
2728
minersCount.value = null
2829
blocksPerMinute.value = null
2930
maxTPS.value = null
30-
const { data } = await axios.get(`${MIDDLEWARE_URL}/v3/stats`)
31+
const { data } = await axios.get(`${MIDDLEWARE_URL}/stats`)
3132
minersCount.value = data.minersCount
3233
blocksPerMinute.value = data.millisecondsPerBlock / 1000 / 60
3334
maxTPS.value = data.maxTransactionsPerSecond
3435
}
3536

3637
async function fetchBlockReward() {
37-
const { data } = await axios.get(`${MIDDLEWARE_URL}/v3/stats/delta?limit=1`)
38+
const { data } = await axios.get(`${MIDDLEWARE_URL}/stats/delta?limit=1`)
3839
blockReward.value = data.data[0].blockReward
3940
}
4041

4142
async function fetchStatus() {
4243
status.value = null
43-
const { data } = await axios.get(`${NODE_URL}/v3/status`)
44+
const { data } = await axios.get(`${NODE_URL}/status`)
4445
status.value = data
4546
}
4647

4748
async function fetchMiners({ queryParameters, limit } = {}) {
4849
miners.value = null
49-
const defaultParameters = `/v3/stats/miners?limit=${limit ?? 10}`
50+
const defaultParameters = `/stats/miners?limit=${limit ?? 10}`
5051
const { data } = await axios.get(`${MIDDLEWARE_URL}${queryParameters || defaultParameters}`)
5152
miners.value = data
5253
}
5354

55+
async function fetchTopMiners({ queryParameters, limit } = {}) {
56+
topMiners.value = null
57+
const defaultParameters = '/stats/miners/top?interval_by=day&min_start_date=2025-02-11&max_start_date=2025-02-11&limit=10&direction=forward'
58+
const { data } = await axios.get(`${MIDDLEWARE_URL}${queryParameters || defaultParameters}`)
59+
topMiners.value = data.data
60+
}
61+
5462
return {
5563
miners,
5664
minersCount,
@@ -60,5 +68,7 @@ export const useMinersStore = defineStore('miners', () => {
6068
maxTPS,
6169
fetchMining,
6270
fetchMiners,
71+
fetchTopMiners,
72+
topMiners,
6373
}
6474
})

src/pages/mining-pools/index.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@
2727
</template>
2828

2929
<script setup>
30-
import { miningHints } from '../../utils/hints/miningHints'
31-
import PageHeader from '~/components/PageHeader.vue'
32-
import AppTab from '~/components/AppTab.vue'
33-
import AppTabs from '~/components/AppTabs.vue'
30+
import { miningHints } from '@/utils/hints/miningHints'
3431
3532
const route = useRoute()
3633
const { push, replace } = useRouter()

0 commit comments

Comments
 (0)