Skip to content

Commit

Permalink
fix: merge two endpoints into single API endpoint
Browse files Browse the repository at this point in the history
- merge the views availability and materialize_views
  availability endpoints into a single API endpoint
  • Loading branch information
kshitij123456 committed Dec 15, 2021
1 parent 0370d67 commit a095c8f
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions chaos_genius/views/data_source_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,32 +427,20 @@ def get_schema_tables(datasource_id, schema_name):
return jsonify({"message":message, "status":status, "table_names":table_names})

@blueprint.route("/<int:datasource_id>/views-available", methods = ["GET"])
def check_views_available(datasource_id):
def check_views_availability(datasource_id):

available = False
views = False
materialize_views = False
message = ""

try:
datasource_name = get_datasource_data_from_id(datasource_id)["connection_type"]
available = TABLE_VIEW_MATERIALIZED_VIEW_AVAILABILITY[datasource_name]["views"]
views = TABLE_VIEW_MATERIALIZED_VIEW_AVAILABILITY[datasource_name]["views"]
materialize_views = TABLE_VIEW_MATERIALIZED_VIEW_AVAILABILITY[datasource_name]["materialized_views"]
except Exception as err:
message = str(err)

return jsonify({"message":message, "available":available})

@blueprint.route("/<int:datasource_id>/materialize-views-available", methods = ["GET"])
def check_materialize_views_available(datasource_id):

available = False
message = ""

try:
datasource_name = get_datasource_data_from_id(datasource_id)["connection_type"]
available = TABLE_VIEW_MATERIALIZED_VIEW_AVAILABILITY[datasource_name]["materialized_views"]
except Exception as err:
message = str(err)

return jsonify({"message":message , "available":available})
return jsonify({"message":message, "available":{"views": views, "materialize_views": materialize_views}})

@blueprint.route("/<int:datasource_id>/<schema_name>/list-views", methods=["GET"])
def get_schema_views(datasource_id, schema_name):
Expand Down

0 comments on commit a095c8f

Please sign in to comment.