From 7d33606f56bf201d969f731a611173132eddfefe Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 19 Jan 2021 17:25:26 -0500 Subject: [PATCH] order the samples by last modified, if that is what is provided as an argument, otherwise base order on created_on --- communicator/api/admin.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/communicator/api/admin.py b/communicator/api/admin.py index 45a0514..92de38c 100644 --- a/communicator/api/admin.py +++ b/communicator/api/admin.py @@ -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