1616
1717from sqlalchemy import desc , select
1818
19- from aperag .db .models import SearchTestHistory
19+ from aperag .db .models import SearchHistory
2020from aperag .db .repositories .base import AsyncRepositoryProtocol
2121
2222
23- class AsyncSearchTestRepositoryMixin (AsyncRepositoryProtocol ):
24- async def create_search_test (
23+ class AsyncSearchRepositoryMixin (AsyncRepositoryProtocol ):
24+ async def create_search (
2525 self ,
2626 user : str ,
2727 collection_id : str ,
@@ -30,9 +30,9 @@ async def create_search_test(
3030 fulltext_search : dict = None ,
3131 graph_search : dict = None ,
3232 items : List [dict ] = None ,
33- ) -> SearchTestHistory :
33+ ) -> SearchHistory :
3434 async def _operation (session ):
35- instance = SearchTestHistory (
35+ instance = SearchHistory (
3636 user = user ,
3737 collection_id = collection_id ,
3838 query = query ,
@@ -48,28 +48,28 @@ async def _operation(session):
4848
4949 return await self .execute_with_transaction (_operation )
5050
51- async def query_search_tests (self , user : str , collection_id : str ) -> List [SearchTestHistory ]:
52- """Query search tests by user and collection"""
51+ async def query_searches (self , user : str , collection_id : str ) -> List [SearchHistory ]:
52+ """Query searches by user and collection"""
5353
5454 async def _query (session ):
5555 stmt = (
56- select (SearchTestHistory )
57- .where (SearchTestHistory .user == user , SearchTestHistory .collection_id == collection_id )
58- .order_by (desc (SearchTestHistory .gmt_created ))
56+ select (SearchHistory )
57+ .where (SearchHistory .user == user , SearchHistory .collection_id == collection_id )
58+ .order_by (desc (SearchHistory .gmt_created ))
5959 )
6060 result = await session .execute (stmt )
6161 return result .scalars ().all ()
6262
6363 return await self ._execute_query (_query )
6464
65- async def delete_search_test (self , user : str , collection_id : str , search_test_id : str ) -> bool :
66- """Delete search test by ID"""
65+ async def delete_search (self , user : str , collection_id : str , search_id : str ) -> bool :
66+ """Delete search by ID"""
6767
6868 async def _operation (session ):
69- stmt = select (SearchTestHistory ).where (
70- SearchTestHistory .id == search_test_id ,
71- SearchTestHistory .user == user ,
72- SearchTestHistory .collection_id == collection_id ,
69+ stmt = select (SearchHistory ).where (
70+ SearchHistory .id == search_id ,
71+ SearchHistory .user == user ,
72+ SearchHistory .collection_id == collection_id ,
7373 )
7474 result = await session .execute (stmt )
7575 instance = result .scalars ().first ()
0 commit comments