You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.3 KiB
34 lines
1.3 KiB
|
2 days ago
|
from datetime import datetime
|
||
|
|
import json
|
||
|
|
from group.models import *
|
||
|
|
from group.utils.update_group_data import *
|
||
|
|
|
||
|
|
|
||
|
|
def main_update_process():
|
||
|
|
# 遍历功能列表并连接DGP线上数据库获取统计数据
|
||
|
|
func_list = GroupFuncs.objects.filter(is_delete=False).all()
|
||
|
|
ugd = UpdateGroupData()
|
||
|
|
failed_list = []
|
||
|
|
for func in func_list:
|
||
|
|
result = ugd.update_group_data(func)
|
||
|
|
if result is not True:
|
||
|
|
failed_list.extend(result)
|
||
|
|
|
||
|
|
# 记录最后运行时间以及最后的错误信息
|
||
|
|
if runtime := GroupRuntime.objects.get(runtime_key='update_datetime'):
|
||
|
|
runtime.runtime_value = datetime.strftime(datetime.now(), '%Y-%m-%d %H:%M:%S')
|
||
|
|
runtime.save()
|
||
|
|
else:
|
||
|
|
GroupRuntime.objects.create(runtime_key='update_datetime',
|
||
|
|
runtime_value=datetime.strftime(datetime.now(), '%Y-%m-%d %H:%M:%S'))
|
||
|
|
if len(failed_list) > 0:
|
||
|
|
print("failed_list", failed_list)
|
||
|
|
if fail := GroupRuntime.objects.get(runtime_key='update_datetime'):
|
||
|
|
fail.runtime_value = json.dumps(failed_list)
|
||
|
|
runtime.save()
|
||
|
|
else:
|
||
|
|
GroupRuntime.objects.create(runtime_key='failed_data', runtime_value=json.dumps(failed_list))
|
||
|
|
|
||
|
|
# 生成影院功能对应数据字典并写入redis
|
||
|
|
set_group_data_to_redis()
|