Переделать получение данных

This commit is contained in:
iriska-gri committed 2024-02-08 15:15:03 +03:00
1 parent 4a92b8430a
commit 2165c55ca1
4 files changed
+87 -84

No files matched your search

@@ -1,6 +1,6 @@
<template>
<v-card class="h-100 d-flex flex-column pa-1" >
<my-helper :pretext="activusers"/>
<!-- <my-helper :pretext="activusers"/> -->
<v-row no-gutters class="overflow-auto h-0">
<v-col class="d-flex flex-column">
<v-chip
@@ -8,10 +8,9 @@
label
class="text-center rounded-0 text-subtitle-1 font-weight-medium"
>
<v-icon start icon="mdi-account-circle-outline"></v-icon>
Самые активные пользователи
</v-chip>
<v-icon start icon="mdi-account-circle-outline"/>
Самые активные пользователи
</v-chip>
<v-divider/>
<v-data-table
v-model:expanded="expanded"
@@ -24,77 +23,58 @@
show-current-page
:sort-by="[{ key: 'info.count', order: 'desc' }]"
density="compact"
>
<template v-slot:headers="{ columns, isSorted, getSortIcon, toggleSort }">
<tr>
<template v-for="column in columns" :key="column.key">
<td>
<v-chip
@click="() => toggleSort(column)"
color="grey-darken-4"
variant="text"
size="small"
label
>
<span
class="mr-2 cursor-pointer"
@click="() => toggleSort(column)"
>
{{ column.title }}
</span>
<template v-if="isSorted(column)">
<v-icon
end
:icon="getSortIcon(column)"
/>
</template>
</v-chip>
<!-- <span class="mr-2 cursor-pointer" @click="() => toggleSort(column)">{{ column.title }}</span>
<template v-if="isSorted(column)">
<v-icon :icon="getSortIcon(column)"></v-icon>
</template> -->
</td>
</template>
</tr>
</template>
<template v-slot:item.user="{ value }">
<!-- <v-chip
color="grey-darken-2"
density="compact"
<template v-slot:item.user="{ value }">
<list-user
:author=value
:from_which = "'top-user'"
/>
</template>
<template v-slot:expanded-row="{ columns, item }">
<tr>
<td :colspan="columns.length">
<v-card class="my-2 elevation-5" >
<v-chip
prepend-icon="mdi-script"
size="small"
class="font-italic my-2"
text="Количество посещенных страниц за выбранный период (всего/уникальные)"
variant="text"
> -->
<!-- <v-icon start icon="mdi-label"></v-icon> -->
<!-- {{ value }} -->
<list-user
:author=value
:from_which = "'top-user'"
/>
<!-- </v-chip> -->
</template>
<template v-slot:expanded-row="{ columns, item }">
<tr>
<td :colspan="columns.length">
<v-card class="my-2 elevation-5" >
<v-chip
prepend-icon="mdi-script"
size="small"
class="font-italic my-2"
text="Количество посещенных страниц за выбранный период (всего/уникальные)"
variant="text"
color="grey"
/>
<v-divider/>
<v-data-table
:headers="subtable"
:items="item.tooltip"
items-per-page=-1
class="subtable"
density="compact"
:sort-by="[{ key: 'count', order: 'desc' }]"
>
color="grey"
/>
<v-divider/>
<v-data-table
:headers="subtable"
:items="item.tooltip"
items-per-page=-1
class="subtable"
density="compact"
:sort-by="[{ key: 'count', order: 'desc' }]"
>
<template v-slot:header.count="{ column, isSorted, getSortIcon }">
<v-btn
max-width="50px"
prepend-icon="mdi-folder-multiple-outline"
variant="text"
>
<v-icon
v-if="isSorted(column)"
:icon="getSortIcon(column)"
/>
</v-btn>
</template>
<template v-slot:header.unic="{ column, isSorted, getSortIcon }">
<v-tooltip location="top">
<template v-slot:activator="{ props }">
<v-btn v-bind="props" max-width="50px" prepend-icon="mdi-folder-outline" variant="text">
<v-icon v-if="isSorted(column)" :icon="getSortIcon(column)"/>
</v-btn>
</template>
<span>Сколько раз посетили в течение заданного периода (1 раз = 1 день)</span>
</v-tooltip>
</template>
<template v-slot:item.count="{ value }">
<v-chip :color="getColor(value)" density="compact">
@@ -142,6 +122,11 @@ export default {
default: {}
},
days: {
type: Number,
default: 0
}
},
setup() {
@@ -158,7 +143,7 @@ export default {
{ title: 'Просмотры', align: 'start', key: 'info.count', maxWidth: '10' },
{ title: 'Сессии', align: 'start', key: 'info.session', maxWidth: '10' },
{ title: 'Страницы', align: 'start', key: 'info.pages',maxWidth: '10' },
{ title: 'Страницы', align: 'start', key: 'info.pages', maxWidth: '10' },
]
@@ -169,9 +154,14 @@ export default {
align: 'start',
sortable: false,
key: 'namepages',
width: '60%',
maxWidth: '60%',
minWidth: '60%',
},
{ title: 'Всего', align: 'start', key: 'count' },
{ title: 'Уникальных', align: 'start', key: 'unic' },
{ title: 'Всего', align: 'start', key: 'count', width: '20%', maxWidth: '20%'
},
{ title: 'Уникальных', align: 'start', key: 'unic', width: '20%', maxWidth: '20%'
},
]
+4 -1
View File
@@ -5,8 +5,11 @@ import { ref } from 'vue'
export const usePortalFilterStore = defineStore('filter', () => {
const date_period = ref({ "startdate": new Date(new Date().getFullYear(), 0, 1),
"enddate": new Date()
"enddate": new Date(),
})
return { date_period }
},
)
+14 -5
View File
@@ -5,6 +5,7 @@
<v-row no-gutters class="h-100 gap">
<v-col lg=2 class="bg-blue">
{{format1(previous.start)}} - {{format1(previous.end)}}
{{days_between_startend}}
</v-col>
<v-col>
<line-chart :dataLineChart="dataLineChart"/>
@@ -16,7 +17,7 @@
<v-col lg=2 class="bg-green">
visiting- (все данные)
<!-- <my-helper :pretext="visiting"/> -->
<my-helper :pretext="visiting"/>
</v-col>
<v-col lg=4 class="d-flex flex-column">
<rating-page :pages_count=pages_count />
@@ -26,6 +27,7 @@
<top-user
:activusers = dataActivusers
:days = days_between_startend
@sortcount=sortcount
/>
@@ -68,7 +70,7 @@ export default {
setup(){
const filterStore = usePortalFilterStore()
const days_between_startend = ref(0)
const visiting = ref([])
const feedback = ref([])
const staff = ref(0)
@@ -76,13 +78,14 @@ setup(){
const dataLineChart = ref({})
const dataActivusers = ref([])
const unicuser = ref([])
const arrPage = ref([])
const previous = ref({start: new Date(), end: new Date()})
const selected_days = ref({today: 'сегодня', year: {start: new Date(), end: new Date()}})
const pages_count = ref({data: {}, title: {}})
const previous_period =() => {
let days_between = Math.floor((new Date(filterStore.date_period.enddate) - new Date(filterStore.date_period.startdate)) / (1000*60*60*24))
days_between += 1
if (filterStore.date_period.startdate == filterStore.date_period.enddate) {
@@ -90,13 +93,17 @@ setup(){
}
previous.value.start = new Date(new Date(filterStore.date_period.startdate).setDate(new Date(filterStore.date_period.startdate).getDate() - days_between))
previous.value.end = new Date(new Date(filterStore.date_period.startdate).setDate(new Date(filterStore.date_period.startdate).getDate() - 1))
days_between_startend.value = days_between
}
pagecounter()
const visition = () => {
axiosApiInstance.get(`api/watcher/counter/`).then(result => {
previous_period()
console.log(format2(previous.value.start), format2(previous.value.end), '---------previous.value--------------');
axiosApiInstance.get(`api/watcher/counter/?start=${format2(previous.value.start)}&end=${format2(previous.value.end)}`).then(result => {
staff.value = result.data.staff
visiting.value = result.data.result
feedback.value = result.data.feedback
@@ -273,6 +280,7 @@ setup(){
watch(()=>filterStore.date_period,(newValue,oldValue)=>{
if(newValue){
visition()
visitionreduce()
title_period()
}
@@ -301,7 +309,8 @@ setup(){
previous,
format1,
selected_days,
sortcount
sortcount,
days_between_startend
// countgrupp,
// activuser,
+3 -2
View File
@@ -19,10 +19,11 @@ class Counter(ListAPIView):
serializer_class = CountSerializer
def get(self, request):
print(request.GET.get("start"), request.GET.get("end"),'--------------------------------------------')
# Посещаемость портала
# res = CountVisitor.objects.filter(visitdate__range=[request.GET.get("start"), request.GET.get("end")]).annotate(Sum('count'))
res = CountVisitor.objects.all().annotate(Sum('count'))
res = CountVisitor.objects.filter(visitdate__range=[request.GET.get("start"), request.GET.get("end")]).annotate(Sum('count'))
# res = CountVisitor.objects.all().annotate(Sum('count'))
result = CountSerializer(res, many=True).data
# Обратная связь