fix: get_mgroup_goals 可复用去年的数据2
This commit is contained in:
parent
a310185c9d
commit
9b44d2c398
|
@ -38,7 +38,7 @@ def get_mgroup_goals(mgroupId, year, reload=False):
|
|||
"""
|
||||
获取工段某年的全部目标值, 以字典形式返回, 带缓存
|
||||
"""
|
||||
goals = Goal.objects.get(mgroup__id=mgroupId, year=year)
|
||||
goals = Goal.objects.filter(mgroup__id=mgroupId, year=year)
|
||||
key = f'mgroup_{mgroupId}_goals_{year}'
|
||||
if reload is False:
|
||||
mgroup_goals = cache.get(key, None)
|
||||
|
@ -47,8 +47,7 @@ def get_mgroup_goals(mgroupId, year, reload=False):
|
|||
mgroup_goals = {}
|
||||
if not goals.exists():
|
||||
# 尝试寻找去年的
|
||||
goals_last_year = Goal.objects.filter(
|
||||
Q(mgroup__id=mgroupId) | Q(mgroup__name=mgroupId), year=year-1)
|
||||
goals_last_year = Goal.objects.filter(mgroup__id=mgroupId, year=year)
|
||||
if goals_last_year.exists():
|
||||
for goal in goals_last_year:
|
||||
# 复用去年的数据创建
|
||||
|
|
Loading…
Reference in New Issue