# update mosqutio tasks
This commit is contained in:
parent
231ff66bfb
commit
8765688eba
|
@ -69,11 +69,20 @@ def update_daily_statistic():
|
|||
_date_list.sort()
|
||||
is_first = True
|
||||
for d in _date_list:
|
||||
obj = MosqPostStatistic.objects.get(date=d)
|
||||
if is_first:
|
||||
history, created = MosqPostStatistic.objects.update_or_create(date=d, total=ret[d], increment=ret[d])
|
||||
if obj:
|
||||
obj.total, obj.increment = ret[d], ret[d]
|
||||
obj.save()
|
||||
else:
|
||||
MosqPostStatistic.objects.create(date=d, total=ret[d], increment=ret[d])
|
||||
else:
|
||||
increment = ret[d] - ret[d-timedelta(days=1)]
|
||||
history, created = MosqPostStatistic.objects.update_or_create(date=d, total=ret[d], increment=increment)
|
||||
if obj:
|
||||
obj.total, obj.increment = ret[d], increment
|
||||
obj.save()
|
||||
else:
|
||||
MosqPostStatistic.objects.create(date=d, total=ret[d], increment=increment)
|
||||
is_first = False
|
||||
return _date_list
|
||||
|
||||
|
|
Loading…
Reference in New Issue