Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alembic version endpoint #2276

Merged
merged 5 commits into from Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions discovery-provider/src/queries/get_alembic_version.py
@@ -0,0 +1,24 @@
from typing import TypedDict

import sqlalchemy
from src.utils import db_session


class AlembicVersion(TypedDict):
version_num: str


def get_alembic_version() -> AlembicVersion:
"""
Fetches the alembic version at head from the database
"""
db = db_session.get_db_read_replica()
with db.scoped_session() as session:
version = session.execute(
sqlalchemy.text(
"""
SELECT * FROM "alembic_version";
"""
)
).first()
return dict(version)
7 changes: 7 additions & 0 deletions discovery-provider/src/queries/health_check.py
Expand Up @@ -3,6 +3,7 @@

from flask import Blueprint, request
from src.api_helpers import success_response
from src.queries.get_alembic_version import get_alembic_version
from src.queries.get_health import get_health, get_latest_ipld_indexed_block
from src.queries.get_latest_play import get_latest_play
from src.queries.get_sol_plays import get_latest_sol_play_check_info
Expand All @@ -21,6 +22,12 @@ def version():
return success_response(disc_prov_version, sign_response=False)


@bp.route("/alembic_version", methods=["GET"])
def alembic_version():
version = get_alembic_version()
return success_response(version)


# Health check for server, db, and redis. Consumes latest block data from redis instead of chain.
# Optional boolean "verbose" flag to output db connection info.
# Optional boolean "enforce_block_diff" flag to error on unhealthy blockdiff.
Expand Down