Skip to content

Commit b1bafa0

Browse files
committed
chore: tidy up
1 parent 37048f8 commit b1bafa0

File tree

3 files changed

+2
-46
lines changed

3 files changed

+2
-46
lines changed

aperag/db/repositories/collection.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,12 @@ async def _query(session):
202202

203203
return await self._execute_query(_query)
204204

205-
async def query_collections_by_ids(self, user: str, collection_ids: List[str]):
205+
async def query_collections_by_ids(self, collection_ids: List[str]):
206206
"""Query multiple collections by their IDs in a single database call"""
207207

208208
async def _query(session):
209209
stmt = select(Collection).where(
210210
Collection.id.in_(collection_ids),
211-
Collection.user == user,
212211
Collection.status != CollectionStatus.DELETED,
213212
)
214213
result = await session.execute(stmt)

aperag/service/agent_chat_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ async def handle_websocket_agent_chat(self, websocket: WebSocket, user: str, bot
175175
# Get default collections once for performance
176176
if bot_config.agent.collections:
177177
agent_collection_ids = [collection.id for collection in bot_config.agent.collections]
178-
agent_collections = await self.db_ops.query_collections_by_ids(user, agent_collection_ids)
178+
agent_collections = await self.db_ops.query_collections_by_ids(agent_collection_ids)
179179
for agent_collection in agent_collections:
180180
default_collections.append(view_models.Collection(
181181
id=agent_collection.id,

aperag/service/collection_service.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -616,49 +616,6 @@ async def delete_search(self, user: str, collection_id: str, search_id: str) ->
616616

617617
return await self.db_ops.delete_search(user, collection_id, search_id)
618618

619-
async def validate_collections_batch(
620-
self, user: str, collections: list[view_models.Collection]
621-
) -> tuple[bool, str]:
622-
"""
623-
Validate multiple collections in a single database call.
624-
625-
Args:
626-
user: User identifier
627-
collections: List of collection objects to validate
628-
629-
Returns:
630-
Tuple of (is_valid, error_message). If valid, error_message is empty.
631-
"""
632-
if not collections:
633-
return True, ""
634-
635-
# Extract collection IDs and validate they exist
636-
collection_ids = []
637-
for collection in collections:
638-
if not collection.id:
639-
return False, "Collection object missing 'id' field"
640-
collection_ids.append(collection.id)
641-
642-
# Remove duplicates while preserving order
643-
unique_collection_ids = list(dict.fromkeys(collection_ids))
644-
645-
try:
646-
# Single database call to get all collections
647-
db_collections = await self.db_ops.query_collections_by_ids(user, unique_collection_ids)
648-
649-
# Create a set of found collection IDs for fast lookup
650-
found_collection_ids = {str(col.id) for col in db_collections}
651-
652-
# Check if all requested collections were found
653-
for collection_id in unique_collection_ids:
654-
if collection_id not in found_collection_ids:
655-
return False, f"Collection {collection_id} not found"
656-
657-
return True, ""
658-
659-
except Exception as e:
660-
return False, f"Failed to validate collections: {str(e)}"
661-
662619
async def test_mineru_token(self, token: str) -> dict:
663620
"""Test the MinerU API token."""
664621
async with httpx.AsyncClient() as client:

0 commit comments

Comments
 (0)