diff --git a/frontend/src/components/BuildStats.vue b/frontend/src/components/BuildStats.vue
index a738f08..17fc0d0 100644
--- a/frontend/src/components/BuildStats.vue
+++ b/frontend/src/components/BuildStats.vue
@@ -1,17 +1,26 @@
-
-
+
+
+
Stats:
- {{ stats.latest }}
- {{ stats.queued }}
- {{ stats.skipped }}
- {{ stats.failed }}
+
+ {{ item.value }}
+
-
+
+
LTO:
- {{ stats.lto.enabled }}
- {{ stats.lto.disabled }}
- {{ stats.lto.unknown }}
+
+ {{ item.value }}
+
@@ -20,6 +29,20 @@
import { onMounted, ref } from 'vue'
import { type Stats } from '@/types/Stats'
+// Define reusable styles and colors
+const sheetStyles = { gap: '50px' }
+const listStyles = { borderRadius: '5px' }
+const colors = {
+ latest: '#069b35',
+ queued: '#b97808',
+ skipped: '#878787',
+ failed: '#b30303',
+ enabled: '#069b35',
+ disabled: '#b30303',
+ unknown: '#878787'
+}
+
+// Reactive stats object
const stats = ref({
latest: 0,
queued: 0,
@@ -32,21 +55,47 @@ const stats = ref({
}
})
-const getStats = () => {
- fetch('https://api.alhp.dev/stats')
- .then((response) => {
- if (!response.ok) throw new Error(response.statusText)
- return response.json()
- })
- .then((statistics) => {
- stats.value = statistics
- })
- .catch((error) => {
- console.error(error)
- })
- .finally(() => {})
+// Map stats and LTO data for simpler rendering in the template
+const statsList = ref([
+ { label: 'latest', value: stats.value.latest, color: colors.latest },
+ { label: 'queued', value: stats.value.queued, color: colors.queued },
+ { label: 'skipped', value: stats.value.skipped, color: colors.skipped },
+ { label: 'failed', value: stats.value.failed, color: colors.failed }
+])
+
+const ltoList = ref([
+ { label: 'enabled', value: stats.value.lto.enabled, color: colors.enabled },
+ { label: 'disabled', value: stats.value.lto.disabled, color: colors.disabled },
+ { label: 'unknown', value: stats.value.lto.unknown, color: colors.unknown }
+])
+
+// Function to fetch stats data (refactored with async/await)
+const getStats = async (): Promise => {
+ try {
+ const response = await fetch('https://api.alhp.dev/stats')
+ if (!response.ok) throw new Error(response.statusText)
+
+ const statistics = await response.json()
+ stats.value = statistics
+
+ // Update lists with fresh data
+ statsList.value = [
+ { label: 'latest', value: stats.value.latest, color: colors.latest },
+ { label: 'queued', value: stats.value.queued, color: colors.queued },
+ { label: 'skipped', value: stats.value.skipped, color: colors.skipped },
+ { label: 'failed', value: stats.value.failed, color: colors.failed }
+ ]
+ ltoList.value = [
+ { label: 'enabled', value: stats.value.lto.enabled, color: colors.enabled },
+ { label: 'disabled', value: stats.value.lto.disabled, color: colors.disabled },
+ { label: 'unknown', value: stats.value.lto.unknown, color: colors.unknown }
+ ]
+ } catch (error) {
+ console.error('Failed to fetch stats:', error)
+ }
}
+// Fetch stats on mount
onMounted(() => {
getStats()
})