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