Skip to content

Commit

Permalink
Merge pull request #141 from tanmoysrt/move_schema_fetchig_function_t…
Browse files Browse the repository at this point in the history
…o_agent_job

chore: move databse schema fetching api to agent job
  • Loading branch information
tanmoysrt authored Oct 28, 2024
2 parents 94b3014 + 270ea87 commit e5e14a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 6 additions & 1 deletion agent/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,12 @@ def get_database_free_tables(self):
except Exception:
return []

def get_database_table_schemas(self):
@job("Fetch Database Table Schema")
def fetch_database_table_schema(self):
return self._fetch_database_table_schema()

@step("Fetch Database Table Schema")
def _fetch_database_table_schema(self):
index_info = self.get_database_table_indexes()
command = f"""SELECT
TABLE_NAME AS `table`,
Expand Down
7 changes: 4 additions & 3 deletions agent/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,11 @@ def backup_site(bench, site):
return {"job": job}


@application.route("/benches/<string:bench>/sites/<string:site>/database/schemas", methods=["GET"])
@application.route("/benches/<string:bench>/sites/<string:site>/database/schema", methods=["POST"])
@validate_bench_and_site
def fetch_database_schemas(bench, site):
return Server().benches[bench].sites[site].get_database_table_schemas()
def fetch_database_table_schema(bench, site):
job = Server().benches[bench].sites[site].fetch_database_table_schema()
return {"job": job}


@application.route("/benches/<string:bench>/sites/<string:site>/database/query/execute", methods=["POST"])
Expand Down

0 comments on commit e5e14a5

Please sign in to comment.