Merge pull request #1200 from webrecorder/run-now-on-update

Call runNow when editing a crawlConfig
This commit is contained in:
Anish Lakhwara 2023-09-19 12:19:35 -07:00 committed by GitHub
commit bd99840fca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -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,

View File

@ -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