fix: fetch stats when lesson is loaded

This commit is contained in:
Jannat Patel
2025-06-30 20:00:13 +05:30
parent 5eaae06ceb
commit 22a2e57642

View File

@@ -77,7 +77,7 @@ import {
NumberChart,
TabButtons,
} from 'frappe-ui'
import { computed, ref } from 'vue'
import { computed, ref, watch } from 'vue'
import VideoBlock from '@/components/VideoBlock.vue'
const show = defineModel<boolean | undefined>()
@@ -102,13 +102,22 @@ const statistics = createListResource({
'source',
'watch_time',
],
auto: true,
cache: ['videoStatistics', props.lessonName],
onSuccess() {
currentTab.value = Object.keys(statisticsData.value)[0]
},
})
watch(
() => props.lessonName,
() => {
if (props.lessonName) {
statistics.filters.lesson = props.lessonName
statistics.reload()
}
}
)
const statisticsData = computed(() => {
const grouped = <Record<string, any[]>>{}
statistics.data.forEach((item: { source: string }) => {