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