소스 검색

fix previous month calculation

Pi 8 달 전
부모
커밋
dd93dd5c36
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      app/rest/trend.py

+ 2 - 1
app/rest/trend.py

@@ -189,7 +189,8 @@ def volume_internal(conn: Connection[TupleRow], path: str, query: FormsDict):
             yield template("done") + template("progress", **progress)
             
             now = datetime.now().date()
-            data = data[data['ts_month'] == date(now.year,now.month-1,1)]
+            prev_month = date(now.year,now.month-1,1) if now.month > 1 else date(now.year-1, 12, 1)
+            data = data[data['ts_month'] == prev_month ]
             group = 'group'
             for g, _g in zip(
                 ('category', 'group'),