Skip to content

Commit 27b8c86

Browse files
authored
Merge pull request #13 from celenium-io/CLS-207-change-histogram-queries
CLS-207 Change histogram queries
2 parents ca25f33 + de13a1a commit 27b8c86

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

components/widgets/BlobsWidget.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Tooltip from "@/components/ui/Tooltip.vue"
99
import { formatBytes } from "@/services/utils"
1010
1111
/** API */
12-
import { fetchHistogram } from "@/services/api/stats"
12+
import { fetchSeries } from "@/services/api/stats"
1313
1414
const days = ref([])
1515
const weeks = ref([])
@@ -18,11 +18,9 @@ const totalSize = ref(0)
1818
const maxSize = ref(0)
1919
2020
onMounted(async () => {
21-
const data = await fetchHistogram({
22-
table: "block_stats",
23-
func: "sum",
21+
const data = await fetchSeries({
22+
table: "blobs_size",
2423
period: "day",
25-
column: "blobs_size",
2624
from: parseInt(DateTime.now().minus({ days: 120 }).ts / 1_000),
2725
})
2826

components/widgets/TransactionsWidget.vue

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Tooltip from "@/components/ui/Tooltip.vue"
99
import { comma, abbreviate } from "@/services/utils"
1010
1111
/** API */
12-
import { fetchHistogram } from "@/services/api/stats"
12+
import { fetchSeries } from "@/services/api/stats"
1313
1414
const histogram = ref([])
1515
@@ -26,9 +26,8 @@ const max = ref(0)
2626
const roundedMax = ref(0)
2727
2828
const getHistogram = async (sectorOffset) => {
29-
const data = await fetchHistogram({
30-
table: "tx",
31-
func: "count",
29+
const data = await fetchSeries({
30+
table: "tx_count",
3231
period: "hour",
3332
from: parseInt(DateTime.now().minus({ hours: 24 - sectorOffset }).ts / 1_000),
3433
})
@@ -45,7 +44,7 @@ const buildHistogram = async () => {
4544
const currentHour = DateTime.now().hour
4645
const currentSector = hoursMap.find((m) => m.includes(currentHour))
4746
const currentHourIdx = currentSector.indexOf(currentHour)
48-
const sectorOffset = 6 - currentHourIdx
47+
const sectorOffset = 5 - currentHourIdx
4948
5049
await getHistogram(sectorOffset)
5150
@@ -54,7 +53,6 @@ const buildHistogram = async () => {
5453
let target = 0
5554
while (items.length) {
5655
if (sectors.value[target].length === 6) target += 1
57-
5856
sectors.value[target].push(items[0])
5957
6058
items.shift()
@@ -88,7 +86,7 @@ const getPercentageRatio = (v) => {
8886
}
8987
9088
const getSectorName = (item) => {
91-
return DateTime.fromISO(item.time).hour
89+
return item.time ? DateTime.fromISO(item.time).hour : DateTime.now().hour
9290
}
9391
</script>
9492

services/api/stats.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
/** Services */
22
import { useServerURL } from "@/services/config"
33

4-
export const fetchHistogram = async ({ table, func, period, column, from, to }) => {
4+
export const fetchSeries = async ({ table, period, column, from, to }) => {
55
try {
6-
const url = new URL(`${useServerURL()}/stats/histogram/${table}/${func}/${period}`)
6+
const url = new URL(`${useServerURL()}/stats/series/${table}/${period}`)
77

88
if (column) url.searchParams.append("column", column)
99
if (from) url.searchParams.append("from", from)
1010
if (to) url.searchParams.append("to", to)
11-
1211
const data = await $fetch(url.href)
1312
return data
1413
} catch (error) {

0 commit comments

Comments
 (0)