feat: 更新十一地市计算逻辑

This commit is contained in:
han0
2024-07-10 16:08:47 +08:00
parent 5afcfc4846
commit 967bb57136
19 changed files with 144 additions and 139 deletions

View File

@@ -41,14 +41,14 @@ class DataNetwork(db.Model, Model, BaseModelMixin):
return result
@classmethod
def get_query(cls, year, month, name, spec, region="福州"):
def get_query(cls, year, month, name, spec=None, region="福州"):
start_date = datetime.date(year, month, 1)
end_date = start_date + relativedelta(months=1)
query = cls.query
query = query.filter(cls.date >= start_date)
query = query.filter(cls.date < end_date)
if name:
query = query.filter(cls.name == name)
query = query.filter(cls.name.like(f'%{name}%'))
if spec:
query = query.filter(cls.spec.like(f'%{spec}%'))
if region: