mirror of
https://github.com/sartography/uva-covid19-testing-communicator.git
synced 2025-02-23 20:38:13 +00:00
order the samples by last modified, if that is what is provided as an argument, otherwise base order on created_on
This commit is contained in:
parent
1cae3ac4f4
commit
7d33606f56
@ -40,11 +40,14 @@ def get_samples(last_modified=None, created_on=None):
|
||||
query = db.session.query(Sample)
|
||||
if last_modified:
|
||||
lm_date = datetime.fromisoformat(last_modified)
|
||||
query = query.filter(Sample.last_modified > lm_date)
|
||||
query = query.filter(Sample.last_modified > lm_date).order_by(Sample.last_modified)
|
||||
if created_on:
|
||||
co_date = datetime.fromisoformat(created_on)
|
||||
query = query.filter(Sample.created_on > co_date)
|
||||
samples = query.order_by(Sample.last_modified).limit(200).all()
|
||||
query = query.filter(Sample.created_on > co_date).order_by(Sample.created_on)
|
||||
else:
|
||||
query = query.order_by(Sample.created_on)
|
||||
|
||||
samples = query.limit(200).all()
|
||||
response = SampleSchema(many=True).dump(samples)
|
||||
return response
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user