fix: resolve out-of-range date error (31 days) in monthly stats calculation
This commit is contained in:
parent
72a85b0ff6
commit
5c504f7747
|
|
@ -139,10 +139,14 @@ def calculate_monthly_stats(target_month: str):
|
|||
|
||||
for pid in plant_ids:
|
||||
# 2. 해당 월의 Daily 합계 조회
|
||||
import calendar
|
||||
year_str, month_str = target_month.split("-")
|
||||
last_day = calendar.monthrange(int(year_str), int(month_str))[1]
|
||||
|
||||
d_res = client.table("daily_stats").select("total_generation") \
|
||||
.eq("plant_id", pid) \
|
||||
.gte("date", f"{target_month}-01") \
|
||||
.lte("date", f"{target_month}-31") \
|
||||
.lte("date", f"{target_month}-{last_day:02d}") \
|
||||
.execute()
|
||||
|
||||
if not d_res.data:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user