|
44 | 44 | UpdatedResponse, |
45 | 45 | DeletedResponseQuota, |
46 | 46 | CrawlSearchValuesResponse, |
47 | | - FAILED_STATES, |
48 | 47 | ) |
49 | 48 | from .pagination import paginated_format, DEFAULT_PAGE_SIZE |
50 | 49 | from .utils import dt_now, get_origin, date_to_str |
@@ -617,11 +616,18 @@ async def bulk_presigned_files( |
617 | 616 | async def validate_all_crawls_successful( |
618 | 617 | self, crawl_ids: List[str], org: Organization |
619 | 618 | ): |
620 | | - """Validate that crawls in list exist and did not fail or else raise exception""" |
621 | | - for crawl_id in crawl_ids: |
622 | | - crawl = await self.get_base_crawl(crawl_id, org) |
623 | | - if crawl.state in FAILED_STATES: |
624 | | - raise HTTPException(status_code=400, detail="invalid_failed_crawl") |
| 619 | + """Validate that crawls in list exist and have a succesful state, or throw""" |
| 620 | + count = self.crawls.count_documents( |
| 621 | + { |
| 622 | + "_id": {"$in": crawl_ids}, |
| 623 | + "oid": org.id, |
| 624 | + "state": {"$in": SUCCESSFUL_STATES}, |
| 625 | + } |
| 626 | + ) |
| 627 | + if count != len(crawl_ids): |
| 628 | + raise HTTPException( |
| 629 | + status_code=400, detail="invalid_failed_or_unfinished_crawl" |
| 630 | + ) |
625 | 631 |
|
626 | 632 | async def add_to_collection( |
627 | 633 | self, crawl_ids: List[str], collection_id: UUID, org: Organization |
|
0 commit comments