2021-03-10 13:55:06 +00:00
|
|
|
from flask import Blueprint, jsonify, request
|
2016-03-03 15:18:12 +00:00
|
|
|
|
|
|
|
|
from app import db, version
|
2023-07-10 11:06:29 -07:00
|
|
|
from app.dao.organization_dao import dao_count_organizations_with_live_services
|
2021-03-10 13:55:06 +00:00
|
|
|
from app.dao.services_dao import dao_count_live_services
|
2016-03-03 15:18:12 +00:00
|
|
|
|
2023-08-29 14:54:30 -07:00
|
|
|
status = Blueprint("status", __name__)
|
2015-12-15 17:14:13 +00:00
|
|
|
|
|
|
|
|
|
2023-08-29 14:54:30 -07:00
|
|
|
@status.route("/", methods=["GET"])
|
|
|
|
|
@status.route("/_status", methods=["GET", "POST"])
|
2016-01-14 16:13:27 +00:00
|
|
|
def show_status():
|
2023-08-29 14:54:30 -07:00
|
|
|
if request.args.get("simple", None):
|
2016-03-03 15:18:12 +00:00
|
|
|
return jsonify(status="ok"), 200
|
|
|
|
|
else:
|
2023-08-29 14:54:30 -07:00
|
|
|
return (
|
|
|
|
|
jsonify(
|
|
|
|
|
status="ok", # This should be considered part of the public API
|
|
|
|
|
git_commit=version.__git_commit__,
|
|
|
|
|
build_time=version.__time__,
|
|
|
|
|
db_version=get_db_version(),
|
|
|
|
|
),
|
|
|
|
|
200,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@status.route("/_status/live-service-and-organization-counts")
|
2023-07-10 11:06:29 -07:00
|
|
|
def live_service_and_organization_counts():
|
2023-08-29 14:54:30 -07:00
|
|
|
return (
|
|
|
|
|
jsonify(
|
|
|
|
|
organizations=dao_count_organizations_with_live_services(),
|
|
|
|
|
services=dao_count_live_services(),
|
|
|
|
|
),
|
|
|
|
|
200,
|
|
|
|
|
)
|
2019-04-11 13:38:21 +01:00
|
|
|
|
|
|
|
|
|
2016-03-03 15:18:12 +00:00
|
|
|
def get_db_version():
|
2023-08-29 14:54:30 -07:00
|
|
|
query = "SELECT version_num FROM alembic_version"
|
2017-10-17 15:51:42 +01:00
|
|
|
full_name = db.session.execute(query).fetchone()[0]
|
|
|
|
|
return full_name
|