|
4 | 4 |
|
5 | 5 | # pylint: disable=too-many-lines |
6 | 6 |
|
7 | | -from typing import List, Optional, TYPE_CHECKING, cast, Dict, Tuple, Annotated, Union |
| 7 | +from typing import ( |
| 8 | + List, |
| 9 | + Optional, |
| 10 | + TYPE_CHECKING, |
| 11 | + cast, |
| 12 | + Dict, |
| 13 | + Tuple, |
| 14 | + Annotated, |
| 15 | + Union, |
| 16 | + Any, |
| 17 | +) |
8 | 18 |
|
9 | 19 | import asyncio |
10 | 20 | import json |
@@ -1174,12 +1184,18 @@ async def get_crawl_config_tag_counts(self, org): |
1174 | 1184 | ).to_list() |
1175 | 1185 | return tags |
1176 | 1186 |
|
1177 | | - async def get_crawl_config_search_values(self, org): |
| 1187 | + async def get_crawl_config_search_values( |
| 1188 | + self, org, profile_ids: Optional[List[UUID]] = None |
| 1189 | + ): |
1178 | 1190 | """List unique names, first seeds, and descriptions from all workflows in org""" |
1179 | | - names = await self.crawl_configs.distinct("name", {"oid": org.id}) |
1180 | | - descriptions = await self.crawl_configs.distinct("description", {"oid": org.id}) |
1181 | | - workflow_ids = await self.crawl_configs.distinct("_id", {"oid": org.id}) |
1182 | | - first_seeds = await self.crawl_configs.distinct("firstSeed", {"oid": org.id}) |
| 1191 | + query: Dict[str, Any] = {"oid": org.id} |
| 1192 | + if profile_ids: |
| 1193 | + query["profileid"] = {"$in": profile_ids} |
| 1194 | + |
| 1195 | + names = await self.crawl_configs.distinct("name", query) |
| 1196 | + descriptions = await self.crawl_configs.distinct("description", query) |
| 1197 | + workflow_ids = await self.crawl_configs.distinct("_id", query) |
| 1198 | + first_seeds = await self.crawl_configs.distinct("firstSeed", query) |
1183 | 1199 |
|
1184 | 1200 | # Remove empty strings |
1185 | 1201 | names = [name for name in names if name] |
@@ -1700,8 +1716,11 @@ async def get_crawl_config_tag_counts(org: Organization = Depends(org_viewer_dep |
1700 | 1716 | @router.get("/search-values", response_model=CrawlConfigSearchValues) |
1701 | 1717 | async def get_crawl_config_search_values( |
1702 | 1718 | org: Organization = Depends(org_viewer_dep), |
| 1719 | + profile_ids: Annotated[ |
| 1720 | + Optional[List[UUID]], Query(alias="profileIds", title="Profile IDs") |
| 1721 | + ] = None, |
1703 | 1722 | ): |
1704 | | - return await ops.get_crawl_config_search_values(org) |
| 1723 | + return await ops.get_crawl_config_search_values(org, profile_ids) |
1705 | 1724 |
|
1706 | 1725 | @router.get("/crawler-channels", response_model=CrawlerChannels) |
1707 | 1726 | async def get_crawler_channels( |
|
0 commit comments