fix: améliorer la gestion des valeurs nulles dans le composant Stats

This commit is contained in:
2026-01-04 17:17:56 +01:00
parent 7b2c34ab87
commit c3aafbf67e

View File

@@ -4,15 +4,15 @@ import { usePrecision } from '@vueuse/math'
const { data: stats } = await useAsyncData<Stats>('stats', () => $fetch('/api/stats'))
const startDate = computed(() => stats.value?.coding.range.start ? new Date(stats.value.coding.range.start) : new Date())
const startDate = computed(() => new Date(stats.value!.coding.range.start))
const yearsCollected = useTimeAgo(startDate).value
const formattedDate = useDateFormat(startDate, 'MMM DD, YYYY').value
const totalHours = usePrecision((stats.value?.coding.grand_total.total_seconds_including_other_language ?? 0) / 3600, 0)
const totalHours = usePrecision((stats.value!.coding.grand_total.total_seconds_including_other_language ?? 0) / 3600, 0)
const topLanguages = computed(() => stats.value?.languages.slice(0, 4) || [])
const topEditors = computed(() => stats.value?.editors.slice(0, 3) || [])
const topOS = computed(() => stats.value?.os.slice(0, 2) || [])
const topLanguages = computed(() => stats.value!.languages.slice(0, 4))
const topEditors = computed(() => stats.value!.editors.slice(0, 3))
const topOS = computed(() => stats.value!.os.slice(0, 2))
</script>
<template>