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

Restore indigo service #858

Merged
merged 6 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion utils/indigo-service/backend/service/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def run_server(port):

@app.teardown_appcontext
def shutdown_session(exception=None):
db_session.remove()
if db_session is not None:
db_session.remove()


if __name__ == "__main__":
Expand Down
265 changes: 153 additions & 112 deletions utils/indigo-service/backend/service/tests/api/indigo_test.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion utils/indigo-service/backend/service/v2/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"port": "5432",
"database": "postgres",
"user": "postgres",
"password": os.environ["POSTGRES_PASSWORD"],
"password": os.environ.get("POSTGRES_PASSWORD", ""),
}

# Flask config
Expand Down
8 changes: 4 additions & 4 deletions utils/indigo-service/backend/service/v2/common_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def version():
description: JSON with service, indigo, bingo and imago vesrions
"""
versions = {}

versions["bingo_version"] = db_session.execute(
"SELECT Bingo.GetVersion();"
).fetchone()[0]
if db_session is not None:
versions["bingo_version"] = db_session.execute(
"SELECT Bingo.GetVersion();"
).fetchone()[0]

indigo = indigo_init()
versions["indigo_version"] = indigo.version()
Expand Down
22 changes: 16 additions & 6 deletions utils/indigo-service/backend/service/v2/db/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,25 @@

from ..common.config import BINGO_POSTGRES

HAS_BINGO_DB = len(BINGO_POSTGRES["password"]) > 0


def connect():
return psycopg2.connect(**BINGO_POSTGRES)


engine = create_engine("postgresql://", creator=connect, convert_unicode=True)

db_session = scoped_session(
sessionmaker(autocommit=False, autoflush=False, bind=engine)
)
Base = declarative_base()
Base.query = db_session.query_property()


if HAS_BINGO_DB:
engine = create_engine(
"postgresql://", creator=connect, convert_unicode=True
)

db_session = scoped_session(
sessionmaker(autocommit=False, autoflush=False, bind=engine)
)
Base.query = db_session.query_property()
else:
engine = None
db_session = None
Loading