Fixed stuff
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pünkösd Marcell 2021-08-11 12:56:56 +02:00
parent 459b3fa6df
commit f90571afc3

View File

@ -159,36 +159,40 @@ class SampleResource(Resource):
filters = [] filters = []
try: try:
first = int(request.args.get('first')) first = int(request.args.get('first'))
except (ValueError, TypeError):
first = None
else:
filters.append( filters.append(
SampleMetadata.id >= first SampleMetadata.id >= first
) )
except ValueError:
first = None
try: try:
after = datetime.fromisoformat(request.args.get('after')) after = datetime.fromisoformat(request.args.get('after'))
except (ValueError, TypeError):
after = None
else:
filters.append( filters.append(
SampleMetadata.timestamp > after SampleMetadata.timestamp > after
) )
except ValueError:
after = None
try: try:
before = datetime.fromisoformat(request.args.get('after')) before = datetime.fromisoformat(request.args.get('after'))
except (ValueError, TypeError):
before = None
else:
filters.append( filters.append(
SampleMetadata.timestamp < before SampleMetadata.timestamp < before
) )
except ValueError:
before = None
if filters: if filters:
query = query.filter(db.and_(*filters)) query = query.filter(db.and_(*filters))
try: try:
limit = int(request.args.get('limit')) limit = int(request.args.get('limit'))
query = query.limit(limit) except (ValueError, TypeError):
except ValueError:
limit = None limit = None
else:
query = query.limit(limit)
## Run query ## ## Run query ##
count = "count" in request.args.get count = "count" in request.args.get