Данные с фильтром
This commit is contained in:
1 parent
05408fd23b
commit
0d30cffbf3
3 files changed
+49
-77
No files matched your search
@@ -122,10 +122,6 @@ export default {
|
|||||||
default: {}
|
default: {}
|
||||||
},
|
},
|
||||||
|
|
||||||
days: {
|
|
||||||
type: Number,
|
|
||||||
default: 0
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<v-col lg=2 class="bg-green">
|
<v-col lg=2 class="bg-green">
|
||||||
visiting- (все данные)
|
visiting- (все данные)
|
||||||
|
|
||||||
<my-helper :pretext="today"/>
|
<my-helper :pretext="dataActivusers"/>
|
||||||
</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 />
|
||||||
@@ -25,11 +25,10 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
<v-col lg=4 class="d-flex flex-column ">
|
<v-col lg=4 class="d-flex flex-column ">
|
||||||
|
|
||||||
<!-- <top-user
|
<top-user
|
||||||
:activusers = dataActivusers
|
:activusers = dataActivusers
|
||||||
:days = days_between_startend
|
|
||||||
@sortcount=sortcount
|
/>
|
||||||
/> -->
|
|
||||||
|
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col class="bg-red">4 </v-col>
|
<v-col class="bg-red">4 </v-col>
|
||||||
@@ -70,31 +69,19 @@ export default {
|
|||||||
|
|
||||||
setup(){
|
setup(){
|
||||||
const filterStore = usePortalFilterStore()
|
const filterStore = usePortalFilterStore()
|
||||||
|
|
||||||
const visiting = ref([])
|
const visiting = ref([])
|
||||||
const feedback = ref([])
|
const feedback = ref([])
|
||||||
|
const for_formulas = ref({})
|
||||||
|
|
||||||
const dataLineChart = ref({})
|
const dataLineChart = ref({})
|
||||||
const dataActivusers = ref([])
|
const dataActivusers = ref([])
|
||||||
const today = ref({})
|
|
||||||
const unicuser = ref([])
|
|
||||||
|
|
||||||
const for_formulas = ref({})
|
const unicuser = ref([])
|
||||||
|
|
||||||
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 =() => {
|
|
||||||
|
|
||||||
// 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) {
|
|
||||||
// days_between = 1
|
|
||||||
// }
|
|
||||||
// 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()
|
pagecounter()
|
||||||
@@ -105,7 +92,7 @@ setup(){
|
|||||||
for_formulas.value = result.data.for_formulas
|
for_formulas.value = result.data.for_formulas
|
||||||
visiting.value = result.data.result
|
visiting.value = result.data.result
|
||||||
feedback.value = result.data.feedback
|
feedback.value = result.data.feedback
|
||||||
today.value = result.data.today
|
|
||||||
|
|
||||||
visitionreduce()
|
visitionreduce()
|
||||||
funActiveUser()
|
funActiveUser()
|
||||||
@@ -124,15 +111,17 @@ setup(){
|
|||||||
|
|
||||||
|
|
||||||
const funLineChart = (data, item) => {
|
const funLineChart = (data, item) => {
|
||||||
if (!data[item.visitdate]) {
|
if (item.visitdate <= format2(filterStore.date_period.enddate)) {
|
||||||
data[item.visitdate] = {count: 0, unic: []}
|
if (!data[item.visitdate]) {
|
||||||
|
data[item.visitdate] = {count: 0, unic: []}
|
||||||
|
}
|
||||||
|
checking_for_entry(data[item.visitdate]['unic'], splitname(item.author))
|
||||||
|
data[item.visitdate].count += item.count
|
||||||
}
|
}
|
||||||
checking_for_entry(data[item.visitdate]['unic'], splitname(item.author))
|
|
||||||
data[item.visitdate].count += item.count
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const funActiveUser = (data, onedata, item) => {
|
const funActiveUser = () => {
|
||||||
|
dataActivusers.value = []
|
||||||
unicuser.value.map(iduser => {
|
unicuser.value.map(iduser => {
|
||||||
|
|
||||||
let activuser ={
|
let activuser ={
|
||||||
@@ -151,20 +140,11 @@ setup(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
let yearpages = {}
|
let yearpages = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let pages = []
|
let pages = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let user = visiting.value.filter(e => e.author.id == iduser)
|
let user = visiting.value.filter(e => e.author.id == iduser)
|
||||||
|
|
||||||
|
|
||||||
const groupUser = user.reduce((acc, item) => {
|
const groupUser = user.reduce((acc, item) => {
|
||||||
|
if (item.visitdate <= format2(filterStore.date_period.enddate)) {
|
||||||
funyearpages(yearpages, item)
|
funyearpages(yearpages, item)
|
||||||
checking_for_entry(pages, item.pages)
|
checking_for_entry(pages, item.pages)
|
||||||
|
|
||||||
@@ -174,12 +154,10 @@ setup(){
|
|||||||
acc['fio'] = splitname(item.author)
|
acc['fio'] = splitname(item.author)
|
||||||
acc['count'] += item.count
|
acc['count'] += item.count
|
||||||
acc['session'] = Object.keys(yearpages).length
|
acc['session'] = Object.keys(yearpages).length
|
||||||
|
}
|
||||||
|
|
||||||
return acc
|
return acc
|
||||||
}, {count: 0})
|
}, {count: 0})
|
||||||
|
|
||||||
|
|
||||||
let arrbigs = []
|
let arrbigs = []
|
||||||
pages.map(namepages => {
|
pages.map(namepages => {
|
||||||
let onetooltip = {
|
let onetooltip = {
|
||||||
@@ -201,13 +179,8 @@ setup(){
|
|||||||
onetooltip.count = pagesData.count
|
onetooltip.count = pagesData.count
|
||||||
onetooltip.unic = pagesData.unic
|
onetooltip.unic = pagesData.unic
|
||||||
arrbigs.push(onetooltip)
|
arrbigs.push(onetooltip)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
activuser.user.id = groupUser.id
|
activuser.user.id = groupUser.id
|
||||||
activuser.user.login = groupUser.login
|
activuser.user.login = groupUser.login
|
||||||
activuser.user.post = groupUser.post
|
activuser.user.post = groupUser.post
|
||||||
@@ -218,33 +191,30 @@ setup(){
|
|||||||
activuser.tooltip = arrbigs
|
activuser.tooltip = arrbigs
|
||||||
dataActivusers.value.push(activuser)
|
dataActivusers.value.push(activuser)
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const funyearpages = (data, item) => {
|
const funyearpages = (data, item) => {
|
||||||
if (!data[item.visitdate]) {
|
if (item.visitdate <= format2(filterStore.date_period.enddate)) {
|
||||||
data[item.visitdate] = {}
|
if (!data[item.visitdate]) {
|
||||||
}
|
data[item.visitdate] = {}
|
||||||
if (!data[item.visitdate][item.pages]) {
|
}
|
||||||
data[item.visitdate][item.pages] = 0
|
if (!data[item.visitdate][item.pages]) {
|
||||||
}
|
data[item.visitdate][item.pages] = 0
|
||||||
data[item.visitdate][item.pages] += item.count
|
}
|
||||||
|
console.log(format2(filterStore.date_period.enddate), item.visitdate, '------------filterStore.date_period.enddate')
|
||||||
|
|
||||||
|
data[item.visitdate][item.pages] += item.count
|
||||||
|
}
|
||||||
|
// console.log(format2(filterStore.date_period.enddate) <= item.visitdate, '------------filterStore.date_period.enddate');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const data_collection = (data, obj) => {
|
const data_collection = (data, obj) => {
|
||||||
|
console.log(data, obj);
|
||||||
|
|
||||||
const groupedData = data.reduce((acc, item) => {
|
const groupedData = data.reduce((acc, item) => {
|
||||||
|
|
||||||
if (obj) {
|
if (!acc[item.pages]) {
|
||||||
funLineChart(obj, item)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item.visitdate >= format2(filterStore.date_period.startdate) && item.visitdate <= format2(filterStore.date_period.enddate)){
|
|
||||||
checking_for_entry(unicuser.value, item.author.id)
|
|
||||||
|
|
||||||
// funActiveUser(activeUser, oneUser, item)
|
|
||||||
|
|
||||||
if (!acc[item.pages]) {
|
|
||||||
acc[item.pages] = {
|
acc[item.pages] = {
|
||||||
now:
|
now:
|
||||||
{unique: [], countall: 0},
|
{unique: [], countall: 0},
|
||||||
@@ -253,12 +223,18 @@ setup(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (obj) {
|
||||||
|
funLineChart(obj, item)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.visitdate >= format2(filterStore.date_period.startdate) && item.visitdate <= format2(filterStore.date_period.enddate)){
|
||||||
|
checking_for_entry(unicuser.value, item.author.id)
|
||||||
|
|
||||||
checking_for_entry(acc[item.pages].year.unique, splitname(item.author))
|
checking_for_entry(acc[item.pages].year.unique, splitname(item.author))
|
||||||
acc[item.pages].year.countall += item.count
|
acc[item.pages].year.countall += item.count
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.visitdate == format2(new Date())) {
|
if (item.visitdate == format2(new Date())) {
|
||||||
console.log(item.visitdate, format2(new Date()), '----------------------------------------');
|
|
||||||
checking_for_entry(acc[item.pages].now.unique, splitname(item.author))
|
checking_for_entry(acc[item.pages].now.unique, splitname(item.author))
|
||||||
acc[item.pages].now.countall += item.count
|
acc[item.pages].now.countall += item.count
|
||||||
}
|
}
|
||||||
@@ -273,9 +249,11 @@ setup(){
|
|||||||
const visitionreduce = () => {
|
const visitionreduce = () => {
|
||||||
|
|
||||||
let lineCharts = {}
|
let lineCharts = {}
|
||||||
|
unicuser.value = []
|
||||||
|
|
||||||
|
|
||||||
|
pages_count.value.data= data_collection(visiting.value, lineCharts)
|
||||||
dataLineChart.value = lineCharts
|
dataLineChart.value = lineCharts
|
||||||
pages_count.value.data = data_collection(visiting.value, lineCharts)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,7 +285,7 @@ setup(){
|
|||||||
format1,
|
format1,
|
||||||
selected_days,
|
selected_days,
|
||||||
for_formulas,
|
for_formulas,
|
||||||
today
|
|
||||||
// countgrupp,
|
// countgrupp,
|
||||||
// activuser,
|
// activuser,
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from rest_framework.response import Response
|
|||||||
from django.views.generic import ListView
|
from django.views.generic import ListView
|
||||||
from .serializers import *
|
from .serializers import *
|
||||||
from datetime import date, datetime, timedelta
|
from datetime import date, datetime, timedelta
|
||||||
from django.db.models import Sum, Count
|
from django.db.models import Sum, Q
|
||||||
from userauth.models import *
|
from userauth.models import *
|
||||||
from feedback.models import *
|
from feedback.models import *
|
||||||
from feedback.serializers import *
|
from feedback.serializers import *
|
||||||
@@ -26,15 +26,13 @@ class Counter(ListAPIView):
|
|||||||
|
|
||||||
# Посещаемость портала
|
# Посещаемость портала
|
||||||
|
|
||||||
res = CountVisitor.objects.filter(visitdate__range=[request.GET.get("start"), request.GET.get("end")]).annotate(Sum('count'))
|
res = CountVisitor.objects.filter(Q(visitdate__range=[request.GET.get("start"), request.GET.get("end")]) | Q(visitdate=date.today()) ).annotate(Sum('count'))
|
||||||
nowdate = CountVisitor.objects.filter(visitdate=date.today()).annotate(Sum('count'))
|
|
||||||
|
|
||||||
|
|
||||||
# Обратная связь
|
# Обратная связь
|
||||||
feed = RatingStatus.objects.all()
|
feed = RatingStatus.objects.all()
|
||||||
|
|
||||||
return Response({'result':CountSerializer(res, many=True).data,
|
return Response({'result':CountSerializer(res, many=True).data,
|
||||||
'today':CountSerializer(nowdate, many=True).data,
|
# 'today':CountSerializer(nowdate, many=True).data,
|
||||||
'feedback': RatingStatusStatSerializer(feed, many=True).data,
|
'feedback': RatingStatusStatSerializer(feed, many=True).data,
|
||||||
'for_formulas': {
|
'for_formulas': {
|
||||||
'staff':DictEmployee.objects.filter(deleted=0).count(),
|
'staff':DictEmployee.objects.filter(deleted=0).count(),
|
||||||
|
|||||||
Reference in new issue
Block a user