Skip to content

Commit

Permalink
api - repair meta data fetch excerption
Browse files Browse the repository at this point in the history
Returns a row as list of tuples.
  • Loading branch information
cherusk committed Nov 16, 2023
1 parent 9176777 commit e775e48
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions api/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@

import logging

import json

AIRFLOW_API_BASE_URL = os.environ.get('AIRFLOW__URL')
AIRFLOW_API_VERSION = "v1"
AIRFLOW_API_AUTH_USER = "airflow"
Expand Down Expand Up @@ -183,14 +185,14 @@ def breeders_name_get(breeder_name): # noqa: E501
__query = meta_data.queries.fetch_meta_data(table_name=db_table_name, breeder_name=breeder_name)
breeder_meta_data = archive.archive_db.execute(db_info=db_config, query=__query, with_result=True)

logging.error(breeder_meta_data)
breeder_meta_data_row = breeder_meta_data[0]

return Response(response=json.dumps(dict(creation_timestamp=breeder_meta_data_row[0].isoformat(),
breeder_definition=breeder_meta_data_row[1])),

return Response(dict(creation_timestamp=breeder_meta_data[0],
breeder_definition=breeder_meta_data[1]),
status=200,
mimetype='application/json')


def breeders_post(content): # noqa: E501
"""breeders_post
Expand Down
4 changes: 2 additions & 2 deletions api/meta_data_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ def insert_breeder_meta(table_name=None, creation_ts=None, meta_state=None):

def remove_breeder_meta(table_name=None, breeder_name=None):
query = f"""
DELETE FROM {table_name} WHERE definition->'breeder'->'name' = {breeder_name};
DELETE FROM {table_name} WHERE definition->>'name' = '{breeder_name}';
"""

return query

def fetch_meta_data(table_name=None, breeder_name=None):
query = f"""
SELECT creation_tsz,definition FROM {table_name} WHERE definition->'breeder'->name = {breeder_name};
SELECT creation_tsz, definition FROM {table_name} WHERE definition->>'name' = '{breeder_name}';
"""

return query

0 comments on commit e775e48

Please sign in to comment.