все переписать

This commit is contained in:
iriska-gri committed 2024-01-30 15:22:18 +03:00
1 parent c43cf66398
commit 2478bb72ab
3 files changed
+67 -26

No files matched your search

@@ -3,30 +3,49 @@
class="text-center" class="text-center"
height="200px" height="200px"
> >
<v-card-title class="text-uppercase"> <v-card-title class="text-uppercase text-body-1">
Посещаемость портала Посещаемость портала
</v-card-title> </v-card-title>
<v-card-text class="pl-0"> <v-card-text class="pl-0">
<v-table fixed-header <v-table
height="430px"> fixed-header
density="comfortable"
class="text-caption"
>
<thead> <thead>
<tr > <tr >
<th></th> <th width="125"></th>
<th>Уникальные пользователи</th> <th class="text-center">Уникальные пользователи</th>
<!-- <th class="text-center"> на {{selected_days.today}} </th> --> <th class="text-center">% от шага </th>
<th class="text-center">за период</th> <th class="text-center">% от периода</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody class="text-caption">
<tr v-for="(val, key) in traffic" :key = key> <tr v-for="(val, key) in traffic" :key = key>
<my-helper :pretext="val"/>
<!-- {{val}} {{key}} --> <td class="text-left">{{val.title}}</td>
<!-- <td class="text-left">{{key}}</td> <td class="text-center ">{{ val.unique.size }} </td>
<td class="text-center">{{ modelrating?val.now.unique.size:val.now.countall }} </td> <td class="text-center">
<td class="text-center">{{ modelrating?val.year.unique.size:val.year.countall }}</td> -->
{{ val.percentage_staff }}</td>
<td>
<v-tooltip location="top"
:text="`${val.info} - ${val.comparison_period.size} чел.`"
>
<template v-slot:activator="{ props }">
<span v-bind="props" >
{{val.percentage_period}}
</span>
</template>
</v-tooltip>
</td>
</tr> </tr>
</tbody> </tbody>
+31 -11
View File
@@ -1,7 +1,7 @@
<template> <template>
<v-row no-gutters class="ma-1"> <v-row no-gutters class="ma-1">
<v-col class="d-flex flex-column gap"> <v-col class="d-flex flex-column gap">
<my-helper :pretext="visiting"/>
<v-row no-gutters class="flex-grow-0"> <v-row no-gutters class="flex-grow-0">
<v-col> <v-col>
<v-toolbar <v-toolbar
@@ -32,7 +32,7 @@
</v-col> </v-col>
</v-row> </v-row>
<v-row no-gutters class="gap flex-grow-0"> <!-- <v-row no-gutters class="gap flex-grow-0">
<v-col lg=3> <v-col lg=3>
<portal-traffic <portal-traffic
@@ -116,7 +116,7 @@
</template> </template>
</v-row> </v-row>
</v-col> </v-col>
</v-row> </v-row> -->
@@ -184,15 +184,24 @@ setup(){
pagecounter() pagecounter()
const weekstart = () => { const weekstart = () => {
// console.log( , '!!!!!!!!!!!!!!!!!!!!!!!!!!');
let days_between = Math.floor((new Date(endate.value) - new Date(startdate.value)) / (1000*60*60*24)) let days_between = Math.floor((new Date(endate.value) - new Date(startdate.value)) / (1000*60*60*24))
previous_period.value = format1(new Date(new Date(startdate.value).setDate(new Date(startdate.value).getDate() - days_between))) if (startdate.value == endate.value) {
days_between = 1
}
previous_period.value = new Date(new Date(startdate.value).setDate(new Date(startdate.value).getDate() - days_between))
} }
const lastperiod = () => { const lastperiod = () => {
let last_day = [] let last_day = []
visiting.value.map((e)=>{ visiting.value.map((e)=>{
if (e.visitdate < format2(endate.value))
if (e.visitdate < format2(endate.value)) {
last_day.push(e.visitdate) last_day.push(e.visitdate)
}
}) })
last_days.value = last_day[last_day.length-1] last_days.value = last_day[last_day.length-1]
} }
@@ -216,15 +225,18 @@ setup(){
} }
const visition = () => { const visition = () => {
let end = format2(new Date(endate.value).setDate(new Date(endate.value).getDate() + 1)) let start = startdate.value
axiosApiInstance.get(`api/watcher/counter/?start=${startdate.value}&end=${end}`).then(result => { if (startdate.value == endate.value) {
start = format2(new Date(startdate.value).setDate(new Date(startdate.value).getDate() -1))
}
axiosApiInstance.get(`api/watcher/counter/?start=${start}&end=${endate.value}`).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
weekstart() weekstart()
lastperiod() lastperiod()
countgrupp()
periodname() periodname()
countgrupp()
})} })}
const countgrupp = () => { const countgrupp = () => {
@@ -232,6 +244,7 @@ setup(){
let portal_traffic = { let portal_traffic = {
now: { now: {
title: '', title: '',
info: '',
unique: new Set(), unique: new Set(),
percentage_staff: 0, percentage_staff: 0,
comparison_period: new Set(), comparison_period: new Set(),
@@ -239,6 +252,7 @@ setup(){
}, },
year: { year: {
title: 'За период', title: 'За период',
info: '',
unique: new Set(), unique: new Set(),
percentage_staff: 0, percentage_staff: 0,
comparison_period: new Set(), comparison_period: new Set(),
@@ -273,10 +287,16 @@ setup(){
// Посещаемость портала для периода 1 день // Посещаемость портала для периода 1 день
if (item.visitdate ==format2(last_days.value)){ if (item.visitdate ==format2(last_days.value)){
portal_traffic.now.comparison_period.add(item.author.id) portal_traffic.now.comparison_period.add(item.author.id)
portal_traffic.now.info = `за ${format1(last_days.value)}`
} }
portal_traffic.year.info = `с ${format1(previous_period.value)} по ${format1(startdate.value)} `
console.log( `${format1(previous_period.value)} >=${format1(item.visitdate)} <= ${format1(startdate.value)}`,'до')
// Посещаемость портала для периода - выбранный период фильтра // Посещаемость портала для периода - выбранный период фильтра
if (item.visitdate >= previous_period.value && item.visitdate <= format2(startdate.value)) { if (item.visitdate >= format2(previous_period.value) && item.visitdate < format2(startdate.value)) {
console.log( `${format1(previous_period.value)} >=${format1(item.visitdate)} < ${format1(startdate.value)}`,'после')
console.log(previous_period.value, format2(startdate.value), '-------------------------------')
portal_traffic.year.comparison_period.add(item.author.id) portal_traffic.year.comparison_period.add(item.author.id)
} }
@@ -310,8 +330,8 @@ setup(){
portal_traffic.now.percentage_period = percentageStaff(portal_traffic.now.comparison_period, portal_traffic.now.unique.size) portal_traffic.now.percentage_period = percentageStaff(portal_traffic.now.comparison_period, portal_traffic.now.unique.size)
portal_traffic.year.percentage_staff = percentageStaff(portal_traffic.year.unique, staff.value) portal_traffic.year.percentage_staff = percentageStaff(portal_traffic.year.unique, staff.value)
portal_traffic.year.percentage_period = percentageStaff(portal_traffic.year.comparison_period, portal_traffic.year.unique.size) portal_traffic.year.percentage_period = percentageStaff(portal_traffic.year.comparison_period, portal_traffic.year.unique.size)
portal_traffic.now.title = selected_days.value.today portal_traffic.now.title = `На ${selected_days.value.today}`
console.log(portal_traffic, 'portal_traffic');
pages_count.value = groupedData pages_count.value = groupedData
traffic.value = portal_traffic traffic.value = portal_traffic
+4 -2
View File
@@ -20,11 +20,13 @@ class Counter(ListAPIView):
def get(self, request): def get(self, request):
# Посещаемость портала # Посещаемость портала
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'))
result = CountSerializer(res, many=True).data result = CountSerializer(res, many=True).data
# Обратная связь # Обратная связь
feed = RatingStatus.objects.filter(usercom__time_create__range=[request.GET.get("start"), request.GET.get("end")]) feed = RatingStatus.objects.all()
feedback = RatingStatusStatSerializer(feed, many=True).data feedback = RatingStatusStatSerializer(feed, many=True).data
return Response({'result':result, 'feedback':feedback, 'staff':DictEmployee.objects.filter(deleted=0).count()}) return Response({'result':result, 'feedback':feedback, 'staff':DictEmployee.objects.filter(deleted=0).count()})