add only_active flag to GET /services/

does what it says on the tin
This commit is contained in:
Leo Hemsted
2016-11-09 11:45:39 +00:00
parent 3cbacecf19
commit d4a300ec7a
4 changed files with 28 additions and 5 deletions

View File

@@ -28,12 +28,17 @@ from app.models import (
from app.statsd_decorators import statsd
def dao_fetch_all_services():
return Service.query.order_by(
def dao_fetch_all_services(only_active=False):
query = Service.query.order_by(
asc(Service.created_at)
).options(
joinedload('users')
).all()
)
if only_active:
query = query.filter(Service.active)
return query.all()
def dao_fetch_service_by_id(service_id):