feat: 变更计算方式
This commit is contained in:
@@ -41,12 +41,14 @@ class DataNetwork(db.Model, Model, BaseModelMixin):
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
def get_query(cls, year, month, name=None, spec=None, region="福州"):
|
||||
def get_query(cls, year, month, name=None, spec=None, region="福州", material_id=None):
|
||||
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 material_id:
|
||||
query = query.filter(cls.material_id == material_id)
|
||||
if name:
|
||||
query = query.filter(cls.name.like(f'%{name}%'))
|
||||
if spec:
|
||||
|
Reference in New Issue
Block a user