abort all chains

This commit is contained in:
Robert 2024-03-22 20:31:55 +07:00
parent 2798e34e4f
commit 70ad69a5b0
No known key found for this signature in database
GPG Key ID: F631C7FD957D5F22
2 changed files with 16 additions and 0 deletions

View File

@ -80,3 +80,16 @@ async def abort_chain_controller(
except Exception: except Exception:
logger.exception("Error during chain abortion") logger.exception("Error during chain abortion")
raise HTTPException(status_code=400, detail="Chain abortion error :)") raise HTTPException(status_code=400, detail="Chain abortion error :)")
@router.post("/abort_all_chains")
async def abort_all_chains_controller(
running_chain_repository: RunningChainRepositoryDependency,
):
try:
await running_chain_repository.delete_all()
return {}
except Exception:
logger.exception("Error during all chains abortion")
raise HTTPException(status_code=400, detail="Chains abortion error :)")

View File

@ -17,3 +17,6 @@ class RunningChainRepository:
async def delete(self, chain_id: str): async def delete(self, chain_id: str):
query = {"chainId": chain_id} query = {"chainId": chain_id}
await self.collection.delete_one(query) await self.collection.delete_one(query)
async def delete_all(self):
await self.collection.delete_many({})