Skip to content

Commit

Permalink
add cli command to remove finished export manually
Browse files Browse the repository at this point in the history
  • Loading branch information
puhoy committed Feb 20, 2022
1 parent 9a9f61b commit e821b00
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
16 changes: 16 additions & 0 deletions hubgrep_indexer/cli_blueprint/repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,19 @@ def prune_exports(keep, hosting_service=None):
for export in old_exports_unified:
print(f"deleting export {export}")
export.delete_file()


@cli_bp.cli.command(help="drop a hosting services 'finished' table")
@click.argument("hosting_service")
def drop_finished_run_table(hosting_service):
hosting_service_api_url = hosting_service
hosting_service: HostingService = HostingService.query.filter_by(
api_url=hosting_service_api_url
).first()
if not hosting_service:
print('could not find hosting service!')
exit(1)

print(f"found {hosting_service}, dropping finished table")
hosting_service.drop_finished_run_table()

10 changes: 6 additions & 4 deletions hubgrep_indexer/models/hosting_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,14 @@ def handle_finished_run(self):
self.export_repos()
logger.debug(f"export for {self} finished")
if not current_app.config['KEEP_LAST_RUN_IN_DB']:
logger.debug(f"dropping table for exported {self}")
self.drop_finished_run_table()

target_table = Repository.get_finished_table_name(self)
with TableHelper._cursor() as cur:
TableHelper.drop_table(cur, target_table)
def drop_finished_run_table(self):
logger.debug(f"dropping table for exported {self}")

target_table = Repository.get_finished_table_name(self)
with TableHelper._cursor() as cur:
TableHelper.drop_table(cur, target_table)

@property
def repos(self) -> ResultProxy:
Expand Down

0 comments on commit e821b00

Please sign in to comment.