Fix filtering on date.
This commit is contained in:
parent
7f97b15532
commit
fbefe633f2
@ -101,8 +101,6 @@ class Operation(db.Model):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def query(cls, session, begin=None, end=None):
|
def query(cls, session, begin=None, end=None):
|
||||||
end = arrow.now().ceil('month').date() if not end else end
|
|
||||||
|
|
||||||
# We have to use a join because the sold is not computed from the
|
# We have to use a join because the sold is not computed from the
|
||||||
# begining.
|
# begining.
|
||||||
base_query = session.query(
|
base_query = session.query(
|
||||||
@ -124,15 +122,18 @@ class Operation(db.Model):
|
|||||||
cls.canceled
|
cls.canceled
|
||||||
).join(
|
).join(
|
||||||
base_query, base_query.c.id == cls.id
|
base_query, base_query.c.id == cls.id
|
||||||
).filter(
|
|
||||||
cls.operation_date >= str(begin),
|
|
||||||
cls.operation_date <= str(end)
|
|
||||||
).order_by(
|
).order_by(
|
||||||
desc(cls.operation_date),
|
desc(cls.operation_date),
|
||||||
cls.value,
|
cls.value,
|
||||||
cls.label,
|
cls.label,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if begin:
|
||||||
|
query = query.filter(cls.operation_date >= str(begin))
|
||||||
|
|
||||||
|
if end:
|
||||||
|
query = query.filter(cls.operation_date <= str(end))
|
||||||
|
|
||||||
return query
|
return query
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user