This commit is contained in:
parent
459b3fa6df
commit
f90571afc3
@ -159,36 +159,40 @@ class SampleResource(Resource):
|
||||
filters = []
|
||||
try:
|
||||
first = int(request.args.get('first'))
|
||||
except (ValueError, TypeError):
|
||||
first = None
|
||||
else:
|
||||
filters.append(
|
||||
SampleMetadata.id >= first
|
||||
)
|
||||
except ValueError:
|
||||
first = None
|
||||
|
||||
try:
|
||||
after = datetime.fromisoformat(request.args.get('after'))
|
||||
except (ValueError, TypeError):
|
||||
after = None
|
||||
else:
|
||||
filters.append(
|
||||
SampleMetadata.timestamp > after
|
||||
)
|
||||
except ValueError:
|
||||
after = None
|
||||
|
||||
try:
|
||||
before = datetime.fromisoformat(request.args.get('after'))
|
||||
except (ValueError, TypeError):
|
||||
before = None
|
||||
else:
|
||||
filters.append(
|
||||
SampleMetadata.timestamp < before
|
||||
)
|
||||
except ValueError:
|
||||
before = None
|
||||
|
||||
if filters:
|
||||
query = query.filter(db.and_(*filters))
|
||||
|
||||
try:
|
||||
limit = int(request.args.get('limit'))
|
||||
query = query.limit(limit)
|
||||
except ValueError:
|
||||
except (ValueError, TypeError):
|
||||
limit = None
|
||||
else:
|
||||
query = query.limit(limit)
|
||||
|
||||
## Run query ##
|
||||
count = "count" in request.args.get
|
||||
|
Loading…
Reference in New Issue
Block a user