fix(backend): call run now when updating crawlConfig #1194

Update backend/btrixcloud/crawlconfigs.py

Co-authored-by: Tessa Walsh <tessa@bitarchivist.net>
This commit is contained in:
Tessa Walsh 2023-09-19 12:05:48 -04:00 committed by Anish Lakhwara
parent 9224f52f51
commit 859f2271da
2 changed files with 10 additions and 2 deletions

View File

@ -220,6 +220,7 @@ class CrawlConfigOps:
async def update_crawl_config(
self, cid: uuid.UUID, org: Organization, user: User, update: UpdateCrawlConfig
):
# pylint: disable=too-many-locals
"""Update name, scale, schedule, and/or tags for an existing crawl config"""
orig_crawl_config = await self.get_crawl_config(cid, org.id)
@ -265,7 +266,9 @@ class CrawlConfigOps:
!= sorted(update.autoAddCollections)
)
if not changed and not metadata_changed:
run_now = update.runNow
if not changed and not metadata_changed and not run_now:
return {
"updated": True,
"settings_changed": changed,
@ -318,11 +321,15 @@ class CrawlConfigOps:
status_code=404, detail=f"Crawl Config '{cid}' not found"
)
return {
ret = {
"updated": True,
"settings_changed": changed,
"metadata_changed": metadata_changed,
}
if run_now:
crawl_id = await self.run_now(str(cid), org, user)
ret["started"] = crawl_id
return ret
async def get_crawl_configs(
self,

View File

@ -259,6 +259,7 @@ class UpdateCrawlConfig(BaseModel):
tags: Optional[List[str]] = None
description: Optional[str] = None
autoAddCollections: Optional[List[UUID4]] = None
runNow: bool = False
# crawl data: revision tracked
schedule: Optional[str] = None