Переделать получение данных
This commit is contained in:
1 parent
4a92b8430a
commit
2165c55ca1
4 files changed
+59
-56
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-card class="h-100 d-flex flex-column pa-1" >
|
<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-row no-gutters class="overflow-auto h-0">
|
||||||
<v-col class="d-flex flex-column">
|
<v-col class="d-flex flex-column">
|
||||||
<v-chip
|
<v-chip
|
||||||
@@ -8,10 +8,9 @@
|
|||||||
label
|
label
|
||||||
class="text-center rounded-0 text-subtitle-1 font-weight-medium"
|
class="text-center rounded-0 text-subtitle-1 font-weight-medium"
|
||||||
>
|
>
|
||||||
<v-icon start icon="mdi-account-circle-outline"></v-icon>
|
<v-icon start icon="mdi-account-circle-outline"/>
|
||||||
Самые активные пользователи
|
Самые активные пользователи
|
||||||
</v-chip>
|
</v-chip>
|
||||||
|
|
||||||
<v-divider/>
|
<v-divider/>
|
||||||
<v-data-table
|
<v-data-table
|
||||||
v-model:expanded="expanded"
|
v-model:expanded="expanded"
|
||||||
@@ -24,54 +23,12 @@
|
|||||||
show-current-page
|
show-current-page
|
||||||
:sort-by="[{ key: 'info.count', order: 'desc' }]"
|
:sort-by="[{ key: 'info.count', order: 'desc' }]"
|
||||||
density="compact"
|
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 }">
|
<template v-slot:item.user="{ value }">
|
||||||
<!-- <v-chip
|
|
||||||
color="grey-darken-2"
|
|
||||||
density="compact"
|
|
||||||
variant="text"
|
|
||||||
> -->
|
|
||||||
<!-- <v-icon start icon="mdi-label"></v-icon> -->
|
|
||||||
<!-- {{ value }} -->
|
|
||||||
<list-user
|
<list-user
|
||||||
:author=value
|
:author=value
|
||||||
:from_which = "'top-user'"
|
:from_which = "'top-user'"
|
||||||
/>
|
/>
|
||||||
<!-- </v-chip> -->
|
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:expanded-row="{ columns, item }">
|
<template v-slot:expanded-row="{ columns, item }">
|
||||||
<tr>
|
<tr>
|
||||||
@@ -95,6 +52,29 @@
|
|||||||
:sort-by="[{ key: 'count', order: 'desc' }]"
|
: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 }">
|
<template v-slot:item.count="{ value }">
|
||||||
<v-chip :color="getColor(value)" density="compact">
|
<v-chip :color="getColor(value)" density="compact">
|
||||||
@@ -142,6 +122,11 @@ export default {
|
|||||||
default: {}
|
default: {}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
days: {
|
||||||
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
@@ -158,7 +143,7 @@ export default {
|
|||||||
|
|
||||||
{ title: 'Просмотры', align: 'start', key: 'info.count', maxWidth: '10' },
|
{ title: 'Просмотры', align: 'start', key: 'info.count', maxWidth: '10' },
|
||||||
{ title: 'Сессии', align: 'start', key: 'info.session', 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',
|
align: 'start',
|
||||||
sortable: false,
|
sortable: false,
|
||||||
key: 'namepages',
|
key: 'namepages',
|
||||||
|
width: '60%',
|
||||||
|
maxWidth: '60%',
|
||||||
|
minWidth: '60%',
|
||||||
|
},
|
||||||
|
{ title: 'Всего', align: 'start', key: 'count', width: '20%', maxWidth: '20%'
|
||||||
|
},
|
||||||
|
{ title: 'Уникальных', align: 'start', key: 'unic', width: '20%', maxWidth: '20%'
|
||||||
},
|
},
|
||||||
{ title: 'Всего', align: 'start', key: 'count' },
|
|
||||||
{ title: 'Уникальных', align: 'start', key: 'unic' },
|
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -5,8 +5,11 @@ import { ref } from 'vue'
|
|||||||
export const usePortalFilterStore = defineStore('filter', () => {
|
export const usePortalFilterStore = defineStore('filter', () => {
|
||||||
|
|
||||||
const date_period = ref({ "startdate": new Date(new Date().getFullYear(), 0, 1),
|
const date_period = ref({ "startdate": new Date(new Date().getFullYear(), 0, 1),
|
||||||
"enddate": new Date()
|
"enddate": new Date(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
return { date_period }
|
return { date_period }
|
||||||
},
|
},
|
||||||
|
|
||||||
)
|
)
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
<v-row no-gutters class="h-100 gap">
|
<v-row no-gutters class="h-100 gap">
|
||||||
<v-col lg=2 class="bg-blue">
|
<v-col lg=2 class="bg-blue">
|
||||||
{{format1(previous.start)}} - {{format1(previous.end)}}
|
{{format1(previous.start)}} - {{format1(previous.end)}}
|
||||||
|
{{days_between_startend}}
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col>
|
<v-col>
|
||||||
<line-chart :dataLineChart="dataLineChart"/>
|
<line-chart :dataLineChart="dataLineChart"/>
|
||||||
@@ -16,7 +17,7 @@
|
|||||||
<v-col lg=2 class="bg-green">
|
<v-col lg=2 class="bg-green">
|
||||||
visiting- (все данные)
|
visiting- (все данные)
|
||||||
|
|
||||||
<!-- <my-helper :pretext="visiting"/> -->
|
<my-helper :pretext="visiting"/>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col lg=4 class="d-flex flex-column">
|
<v-col lg=4 class="d-flex flex-column">
|
||||||
<rating-page :pages_count=pages_count />
|
<rating-page :pages_count=pages_count />
|
||||||
@@ -26,6 +27,7 @@
|
|||||||
|
|
||||||
<top-user
|
<top-user
|
||||||
:activusers = dataActivusers
|
:activusers = dataActivusers
|
||||||
|
:days = days_between_startend
|
||||||
@sortcount=sortcount
|
@sortcount=sortcount
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -68,7 +70,7 @@ export default {
|
|||||||
|
|
||||||
setup(){
|
setup(){
|
||||||
const filterStore = usePortalFilterStore()
|
const filterStore = usePortalFilterStore()
|
||||||
|
const days_between_startend = ref(0)
|
||||||
const visiting = ref([])
|
const visiting = ref([])
|
||||||
const feedback = ref([])
|
const feedback = ref([])
|
||||||
const staff = ref(0)
|
const staff = ref(0)
|
||||||
@@ -76,13 +78,14 @@ setup(){
|
|||||||
const dataLineChart = ref({})
|
const dataLineChart = ref({})
|
||||||
const dataActivusers = ref([])
|
const dataActivusers = ref([])
|
||||||
const unicuser = ref([])
|
const unicuser = ref([])
|
||||||
const arrPage = ref([])
|
|
||||||
|
|
||||||
const previous = ref({start: new Date(), end: new Date()})
|
const previous = ref({start: new Date(), end: new Date()})
|
||||||
const selected_days = ref({today: 'сегодня', year: {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 pages_count = ref({data: {}, title: {}})
|
||||||
|
|
||||||
const previous_period =() => {
|
const previous_period =() => {
|
||||||
|
|
||||||
let days_between = Math.floor((new Date(filterStore.date_period.enddate) - new Date(filterStore.date_period.startdate)) / (1000*60*60*24))
|
let days_between = Math.floor((new Date(filterStore.date_period.enddate) - new Date(filterStore.date_period.startdate)) / (1000*60*60*24))
|
||||||
days_between += 1
|
days_between += 1
|
||||||
if (filterStore.date_period.startdate == filterStore.date_period.enddate) {
|
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.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))
|
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()
|
pagecounter()
|
||||||
|
|
||||||
const visition = () => {
|
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
|
staff.value = result.data.staff
|
||||||
visiting.value = result.data.result
|
visiting.value = result.data.result
|
||||||
feedback.value = result.data.feedback
|
feedback.value = result.data.feedback
|
||||||
@@ -273,6 +280,7 @@ setup(){
|
|||||||
|
|
||||||
watch(()=>filterStore.date_period,(newValue,oldValue)=>{
|
watch(()=>filterStore.date_period,(newValue,oldValue)=>{
|
||||||
if(newValue){
|
if(newValue){
|
||||||
|
visition()
|
||||||
visitionreduce()
|
visitionreduce()
|
||||||
title_period()
|
title_period()
|
||||||
}
|
}
|
||||||
@@ -301,7 +309,8 @@ setup(){
|
|||||||
previous,
|
previous,
|
||||||
format1,
|
format1,
|
||||||
selected_days,
|
selected_days,
|
||||||
sortcount
|
sortcount,
|
||||||
|
days_between_startend
|
||||||
// countgrupp,
|
// countgrupp,
|
||||||
// activuser,
|
// activuser,
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,11 @@ class Counter(ListAPIView):
|
|||||||
serializer_class = CountSerializer
|
serializer_class = CountSerializer
|
||||||
|
|
||||||
def get(self, request):
|
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.filter(visitdate__range=[request.GET.get("start"), request.GET.get("end")]).annotate(Sum('count'))
|
||||||
res = CountVisitor.objects.all().annotate(Sum('count'))
|
# res = CountVisitor.objects.all().annotate(Sum('count'))
|
||||||
result = CountSerializer(res, many=True).data
|
result = CountSerializer(res, many=True).data
|
||||||
|
|
||||||
# Обратная связь
|
# Обратная связь
|
||||||
|
|||||||
Reference in new issue
Block a user