Статистика
This commit is contained in:
1 parent
92b5da82de
commit
949a7295cd
3 files changed
+21
-47
No files matched your search
+15
-23
@@ -16,39 +16,33 @@ class Counter(ListAPIView):
|
||||
permission_classes = (AllowAny,)
|
||||
serializer_class = CountSerializer
|
||||
|
||||
# def get(self, request):
|
||||
# res = CountVisitor.objects.values('page').annotate(Sum('count'))
|
||||
# users = CountVisitor.objects.values('page', 'user__username').annotate(Sum('count'))
|
||||
# outuser = DictEmployee.objects.values('login', 'fio')
|
||||
# pUser = pd.DataFrame.from_records(users)
|
||||
# pOutUser = pd.DataFrame.from_records(outuser)
|
||||
# h = pUser.merge(pOutUser, how="left", left_on="user__username", right_on="login")
|
||||
def get(self, request):
|
||||
res = CountVisitor.objects.values('pages__page').filter(visitdate__year='2023', visitdate__month='01', visitdate__day='21').annotate(Sum('count'))
|
||||
# users = CountVisitor.objects.values('page', 'user__username').annotate(Sum('count'))
|
||||
# outuser = DictEmployee.objects.values('login', 'fio')
|
||||
# pUser = pd.DataFrame.from_records(users)
|
||||
# pOutUser = pd.DataFrame.from_records(outuser)
|
||||
# h = pUser.merge(pOutUser, how="left", left_on="user__username", right_on="login")
|
||||
|
||||
# for x in users:
|
||||
# if x['user__username'] is not None:
|
||||
# x['user__username'] = h.loc[h['login']==x['user__username']]['fio'].unique()[0]
|
||||
# else:
|
||||
# x['user__username'] = 'Анонимные'
|
||||
# for x in users:
|
||||
# if x['user__username'] is not None:
|
||||
# x['user__username'] = h.loc[h['login']==x['user__username']]['fio'].unique()[0]
|
||||
# else:
|
||||
# x['user__username'] = 'Анонимные'
|
||||
|
||||
# return Response({"pages":res, "users": users})
|
||||
# return Response({"pages":res, "users": users})
|
||||
return Response(res)
|
||||
|
||||
|
||||
def post(self, request):
|
||||
|
||||
print('ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd')
|
||||
|
||||
|
||||
|
||||
|
||||
myfullPath = request.data['fullPath']
|
||||
if "?" in myfullPath:
|
||||
myfullPath= myfullPath.split("?")[0]
|
||||
print(request.data['page'], 'request.data[page]-------')
|
||||
|
||||
page, create = Pages.objects.get_or_create(page=request.data['page'], fullPath=myfullPath, ico=request.data['ico'])
|
||||
|
||||
if request.data['user__id'] is not None:
|
||||
watch,create = CountVisitor.objects.get_or_create(user = User(id=request.data['user__id']),pages=page, visitdate=date.today())
|
||||
print('if ----------------------------')
|
||||
else:
|
||||
watch,create = CountVisitor.objects.get_or_create(user__id__isnull=True, pages=page, visitdate=date.today())
|
||||
watch.count+=1
|
||||
@@ -58,8 +52,6 @@ class Counter(ListAPIView):
|
||||
"visittoday":CountVisitor.objects.filter(visitdate=date.today(), pages=page.id).aggregate(Sum('count'))['count__sum'],
|
||||
"uniqtoday" : CountVisitor.objects.filter(visitdate=date.today(), pages=page.id).count()
|
||||
}
|
||||
|
||||
|
||||
|
||||
return Response(res)
|
||||
|
||||
|
||||
Reference in new issue
Block a user