Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/app/search/api/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from src.app.search.services.search import SearchService, get_search_service
from src.app.services.data_collection import get_data_collection_service
from src.app.services.sql_db.queries import (
get_collections_sync,
get_collections_info_sync,
get_documents_payload_by_ids_sync,
get_nb_docs_sync,
)
Expand Down Expand Up @@ -67,16 +67,17 @@ def get_params(

@router.get("/collections")
async def get_corpus():
collections = await run_in_threadpool(get_collections_sync)
collections = await run_in_threadpool(get_collections_info_sync)

return [
{
"name": name,
"lang": lang,
"model": model,
"corpus": f"{name}_{lang}_{model}",
"name": source_name,
"category": (
category_name.replace(" ", "_").lower() if category_name else None
),
"is_active": is_active,
}
for name, lang, model in collections
for source_name, is_active, category_name in collections
]


Expand Down
11 changes: 11 additions & 0 deletions src/app/services/sql_db/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from sqlalchemy import func, select
from welearn_database.data.enumeration import Step
from welearn_database.data.models import (
Category,
ChatMessage,
ContextDocument,
Corpus,
Expand Down Expand Up @@ -47,6 +48,16 @@ def get_collections_sync():
return s.execute(statement).all()


def get_collections_info_sync():
stmt = select(
Corpus.source_name, Corpus.is_active, Category.title.label("category_name")
).outerjoin(Category, Corpus.category_id == Category.id)

with session_maker() as session:
results = session.execute(stmt).all()
return results


def get_nb_docs_sync():
statement = select(QtyDocumentInQdrant.document_in_qdrant)
with session_maker() as s:
Expand Down
Loading