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:
parent
9224f52f51
commit
859f2271da
@ -220,6 +220,7 @@ class CrawlConfigOps:
|
|||||||
async def update_crawl_config(
|
async def update_crawl_config(
|
||||||
self, cid: uuid.UUID, org: Organization, user: User, update: UpdateCrawlConfig
|
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"""
|
"""Update name, scale, schedule, and/or tags for an existing crawl config"""
|
||||||
|
|
||||||
orig_crawl_config = await self.get_crawl_config(cid, org.id)
|
orig_crawl_config = await self.get_crawl_config(cid, org.id)
|
||||||
@ -265,7 +266,9 @@ class CrawlConfigOps:
|
|||||||
!= sorted(update.autoAddCollections)
|
!= 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 {
|
return {
|
||||||
"updated": True,
|
"updated": True,
|
||||||
"settings_changed": changed,
|
"settings_changed": changed,
|
||||||
@ -318,11 +321,15 @@ class CrawlConfigOps:
|
|||||||
status_code=404, detail=f"Crawl Config '{cid}' not found"
|
status_code=404, detail=f"Crawl Config '{cid}' not found"
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
ret = {
|
||||||
"updated": True,
|
"updated": True,
|
||||||
"settings_changed": changed,
|
"settings_changed": changed,
|
||||||
"metadata_changed": metadata_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(
|
async def get_crawl_configs(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@ -259,6 +259,7 @@ class UpdateCrawlConfig(BaseModel):
|
|||||||
tags: Optional[List[str]] = None
|
tags: Optional[List[str]] = None
|
||||||
description: Optional[str] = None
|
description: Optional[str] = None
|
||||||
autoAddCollections: Optional[List[UUID4]] = None
|
autoAddCollections: Optional[List[UUID4]] = None
|
||||||
|
runNow: bool = False
|
||||||
|
|
||||||
# crawl data: revision tracked
|
# crawl data: revision tracked
|
||||||
schedule: Optional[str] = None
|
schedule: Optional[str] = None
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user