Simplify by omitting nonsense conditions.
Don't default locations and time ranges as the query doesn't work without them being specified.
List comprehensions are clearer and more consise than loops.