Add method to count of live services and orgs

So that we don’t have to update the home page manually any more.
This commit is contained in:
Chris Hill-Scott
2019-04-11 13:38:21 +01:00
parent 3845e90ee4
commit 6bfd999de2
5 changed files with 83 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ from app.models import (
Organisation,
Domain,
InvitedOrganisationUser,
Service,
User
)
@@ -16,6 +17,14 @@ def dao_get_organisations():
).all()
def dao_count_organsations_with_live_services():
return db.session.query(Organisation.id).join(Organisation.services).filter(
Service.active.is_(True),
Service.restricted.is_(False),
Service.count_as_live.is_(True),
).distinct().count()
def dao_get_organisation_services(organisation_id):
return Organisation.query.filter_by(
id=organisation_id