diff --git a/apps/enm/tasks.py b/apps/enm/tasks.py index f978b398..4b3eaaba 100644 --- a/apps/enm/tasks.py +++ b/apps/enm/tasks.py @@ -365,6 +365,7 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s, mytz = tz.gettz(settings.TIME_ZONE) dt = datetime.datetime(year=year, month=month, day=day, hour=hour, tzinfo=mytz) sflog = get_sflog(mgroup, dt) + team = None if sflog: year_s, month_s, day_s = sflog.get_ymd team = sflog.team @@ -387,7 +388,7 @@ def cal_enstat(type, sflogId, mgroupId, year, month, day, hour, year_s, month_s, enstat, _ = EnStat.objects.get_or_create( type="day_s", mgroup=mgroup, year_s=year_s, month_s=month_s, day_s=day_s, defaults={"type": "day_s", "mgroup": mgroup, "year_s": year_s, "month_s": month_s, "day_s": day_s} ) - elif type == "month_st": + elif type == "month_st" and team: enstat, _ = EnStat.objects.get_or_create( type="month_st", mgroup=mgroup, team=team, year_s=year_s, month_s=month_s, defaults={"type": "month_st", "mgroup": mgroup, "year_s": year_s, "month_s": month_s, "team": team} )