You've already forked AstralRinth
forked from didirus/AstralRinth
fix: race condition for chart query param (#4677)
This commit is contained in:
@@ -8,6 +8,11 @@
|
|||||||
{{ analytics.error.value }}
|
{{ analytics.error.value }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else-if="!isInitialized || analytics.loading.value" class="universal-card">
|
||||||
|
<h2>
|
||||||
|
<span class="label__title">Loading analytics...</span>
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
<div v-else class="graphs">
|
<div v-else class="graphs">
|
||||||
<div class="graphs__vertical-bar">
|
<div class="graphs__vertical-bar">
|
||||||
<client-only>
|
<client-only>
|
||||||
@@ -419,6 +424,7 @@ const isUsingProjectColors = computed({
|
|||||||
const startDate = ref(dayjs().startOf('day'))
|
const startDate = ref(dayjs().startOf('day'))
|
||||||
const endDate = ref(dayjs().endOf('day'))
|
const endDate = ref(dayjs().endOf('day'))
|
||||||
const timeResolution = ref(30)
|
const timeResolution = ref(30)
|
||||||
|
const isInitialized = ref(false)
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
// Load cached data and range from localStorage - cache.
|
// Load cached data and range from localStorage - cache.
|
||||||
@@ -449,6 +455,8 @@ onMounted(() => {
|
|||||||
startDate.value = ranges.startDate
|
startDate.value = ranges.startDate
|
||||||
endDate.value = ranges.endDate
|
endDate.value = ranges.endDate
|
||||||
timeResolution.value = selectedRange.value.timeResolution
|
timeResolution.value = selectedRange.value.timeResolution
|
||||||
|
|
||||||
|
isInitialized.value = true
|
||||||
})
|
})
|
||||||
|
|
||||||
const internalRange: Ref<RangeObject> = ref(null as unknown as RangeObject)
|
const internalRange: Ref<RangeObject> = ref(null as unknown as RangeObject)
|
||||||
@@ -482,6 +490,7 @@ const analytics = useFetchAllAnalytics(
|
|||||||
startDate,
|
startDate,
|
||||||
endDate,
|
endDate,
|
||||||
timeResolution,
|
timeResolution,
|
||||||
|
isInitialized,
|
||||||
)
|
)
|
||||||
|
|
||||||
const formattedCategorySubtitle = computed(() => {
|
const formattedCategorySubtitle = computed(() => {
|
||||||
|
|||||||
@@ -307,6 +307,7 @@ export const useFetchAllAnalytics = (
|
|||||||
startDate = ref(dayjs().subtract(30, 'days')),
|
startDate = ref(dayjs().subtract(30, 'days')),
|
||||||
endDate = ref(dayjs()),
|
endDate = ref(dayjs()),
|
||||||
timeResolution = ref(1440),
|
timeResolution = ref(1440),
|
||||||
|
isInitialized = ref(false),
|
||||||
) => {
|
) => {
|
||||||
const downloadData = ref(null)
|
const downloadData = ref(null)
|
||||||
const viewData = ref(null)
|
const viewData = ref(null)
|
||||||
@@ -388,8 +389,18 @@ export const useFetchAllAnalytics = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[() => startDate.value, () => endDate.value, () => timeResolution.value, () => projects.value],
|
[
|
||||||
|
() => startDate.value,
|
||||||
|
() => endDate.value,
|
||||||
|
() => timeResolution.value,
|
||||||
|
() => projects.value,
|
||||||
|
() => isInitialized.value,
|
||||||
|
],
|
||||||
async () => {
|
async () => {
|
||||||
|
if (!isInitialized.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const q = {
|
const q = {
|
||||||
start_date: startDate.value.toISOString(),
|
start_date: startDate.value.toISOString(),
|
||||||
end_date: endDate.value.toISOString(),
|
end_date: endDate.value.toISOString(),
|
||||||
@@ -456,5 +467,6 @@ export const useFetchAllAnalytics = (
|
|||||||
totalData,
|
totalData,
|
||||||
loading,
|
loading,
|
||||||
error,
|
error,
|
||||||
|
isInitialized,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user