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

@@ -5,6 +5,8 @@ from flask import (
)
from app import db, version
from app.dao.services_dao import dao_count_live_services
from app.dao.organisation_dao import dao_count_organsations_with_live_services
status = Blueprint('status', __name__)
@@ -23,6 +25,14 @@ def show_status():
db_version=get_db_version()), 200
@status.route('/_status/live-service-and-organisation-counts')
def live_service_and_organisation_counts():
return jsonify(
organisations=dao_count_organsations_with_live_services(),
services=dao_count_live_services(),
), 200
def get_db_version():
query = 'SELECT version_num FROM alembic_version'
full_name = db.session.execute(query).fetchone()[0]