|
@@ -27,8 +27,7 @@ from ratelimit.decorators import ratelimit
|
|
|
|
|
|
from Ansjer.config import AuthCode_Expire, SERVER_DOMAIN, APNS_CONFIG, JPUSH_CONFIG, FCM_CONFIG, TUTK_PUSH_DOMAIN
|
|
from Ansjer.config import AuthCode_Expire, SERVER_DOMAIN, APNS_CONFIG, JPUSH_CONFIG, FCM_CONFIG, TUTK_PUSH_DOMAIN
|
|
from Controller.CheckUserData import DataValid, date_handler, RandomStr
|
|
from Controller.CheckUserData import DataValid, date_handler, RandomStr
|
|
-from Model.models import Device_User, Role, UidPushModel, UserOauth2Model, UserExModel, Device_Info, UidSetModel, \
|
|
|
|
- UserAppFrequencyModel
|
|
|
|
|
|
+from Model.models import Device_User, Role, UidPushModel, UserOauth2Model, UserExModel, Device_Info, UidSetModel
|
|
from Object.AWS.SesClassObject import SesClassObject
|
|
from Object.AWS.SesClassObject import SesClassObject
|
|
from Object.AliSmsObject import AliSmsObject
|
|
from Object.AliSmsObject import AliSmsObject
|
|
from Object.RedisObject import RedisObject
|
|
from Object.RedisObject import RedisObject
|
|
@@ -2962,49 +2961,50 @@ class UserAppFrequencyView(TemplateView):
|
|
return response.json(404)
|
|
return response.json(404)
|
|
|
|
|
|
def do_refresh(self, request_dict, userID, response):
|
|
def do_refresh(self, request_dict, userID, response):
|
|
- type = request_dict.get('type', None)
|
|
|
|
- month = request_dict.get('month', None)
|
|
|
|
- if not type or not month:
|
|
|
|
- return response.json(444, 'type')
|
|
|
|
- else:
|
|
|
|
- type = int(type)
|
|
|
|
- now_time = int(time.time())
|
|
|
|
- month = int(month)
|
|
|
|
- uaf_qs = UserAppFrequencyModel.objects.filter(user__userID=userID)
|
|
|
|
-
|
|
|
|
- if not uaf_qs.exists():
|
|
|
|
- user = Device_User.objects.filter(userID=userID)[0]
|
|
|
|
- data = {
|
|
|
|
- 'user': user,
|
|
|
|
- 'type': type,
|
|
|
|
- 'data_time': month,
|
|
|
|
- 'add_time': now_time,
|
|
|
|
- 'update_time': now_time,
|
|
|
|
- }
|
|
|
|
- UserAppFrequencyModel.objects.create(**data)
|
|
|
|
- return response.json(0)
|
|
|
|
- else:
|
|
|
|
- updateMonth = time.strftime('%m', time.localtime(month))
|
|
|
|
- uaf = uaf_qs.values('id', 'type', 'data_time')[0]
|
|
|
|
- dbMonth = time.strftime('%m', time.localtime(int(uaf['data_time'])))
|
|
|
|
- print('update month is ' + updateMonth)
|
|
|
|
- print('db month is ' + dbMonth)
|
|
|
|
- if updateMonth == dbMonth:
|
|
|
|
- UserAppFrequencyModel.objects.filter(id=uaf['id']).update(type=type)
|
|
|
|
- return response.json(0)
|
|
|
|
- elif updateMonth > dbMonth:
|
|
|
|
- user = Device_User.objects.filter(userID=userID)[0]
|
|
|
|
- data = {
|
|
|
|
- 'user': user,
|
|
|
|
- 'type': type,
|
|
|
|
- 'data_time': month,
|
|
|
|
- 'add_time': now_time,
|
|
|
|
- 'update_time': now_time,
|
|
|
|
- }
|
|
|
|
- UserAppFrequencyModel.objects.create(**data)
|
|
|
|
- return response.json(0)
|
|
|
|
- else:
|
|
|
|
- return response.json(444, 'month')
|
|
|
|
|
|
+ return response.json(0)
|
|
|
|
+ # type = request_dict.get('type', None)
|
|
|
|
+ # month = request_dict.get('month', None)
|
|
|
|
+ # if not type or not month:
|
|
|
|
+ # return response.json(444, 'type')
|
|
|
|
+ # else:
|
|
|
|
+ # type = int(type)
|
|
|
|
+ # now_time = int(time.time())
|
|
|
|
+ # month = int(month)
|
|
|
|
+ # uaf_qs = UserAppFrequencyModel.objects.filter(user__userID=userID)
|
|
|
|
+ #
|
|
|
|
+ # if not uaf_qs.exists():
|
|
|
|
+ # user = Device_User.objects.filter(userID=userID)[0]
|
|
|
|
+ # data = {
|
|
|
|
+ # 'user': user,
|
|
|
|
+ # 'type': type,
|
|
|
|
+ # 'data_time': month,
|
|
|
|
+ # 'add_time': now_time,
|
|
|
|
+ # 'update_time': now_time,
|
|
|
|
+ # }
|
|
|
|
+ # UserAppFrequencyModel.objects.create(**data)
|
|
|
|
+ # return response.json(0)
|
|
|
|
+ # else:
|
|
|
|
+ # updateMonth = time.strftime('%m', time.localtime(month))
|
|
|
|
+ # uaf = uaf_qs.values('id', 'type', 'data_time')[0]
|
|
|
|
+ # dbMonth = time.strftime('%m', time.localtime(int(uaf['data_time'])))
|
|
|
|
+ # print('update month is ' + updateMonth)
|
|
|
|
+ # print('db month is ' + dbMonth)
|
|
|
|
+ # if updateMonth == dbMonth:
|
|
|
|
+ # UserAppFrequencyModel.objects.filter(id=uaf['id']).update(type=type)
|
|
|
|
+ # return response.json(0)
|
|
|
|
+ # elif updateMonth > dbMonth:
|
|
|
|
+ # user = Device_User.objects.filter(userID=userID)[0]
|
|
|
|
+ # data = {
|
|
|
|
+ # 'user': user,
|
|
|
|
+ # 'type': type,
|
|
|
|
+ # 'data_time': month,
|
|
|
|
+ # 'add_time': now_time,
|
|
|
|
+ # 'update_time': now_time,
|
|
|
|
+ # }
|
|
|
|
+ # UserAppFrequencyModel.objects.create(**data)
|
|
|
|
+ # return response.json(0)
|
|
|
|
+ # else:
|
|
|
|
+ # return response.json(444, 'month')
|
|
|
|
|
|
|
|
|
|
|
|
|