File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from uuid import UUID
22
3- from sqlalchemy import func , select
3+ from sqlalchemy import func , select , update
44from sqlalchemy .dialects .postgresql import insert
55from sqlalchemy .ext .asyncio import AsyncSession
66
@@ -60,9 +60,9 @@ async def upsert_chunk(
6060
6161 @staticmethod
6262 async def update_source_synced (session : AsyncSession , source_id : UUID ) -> None :
63- result = await session .execute (select ( SourceRow ). where ( SourceRow . id == source_id ))
64- source = result . scalar_one ( )
65- source . last_synced_at = func . now ( )
63+ await session .execute (
64+ update ( SourceRow ). where ( SourceRow . id == source_id ). values ( last_synced_at = func . now () )
65+ )
6666
6767 @staticmethod
6868 async def top_k_chunks (
Original file line number Diff line number Diff line change 11import hashlib
22
33from langchain_text_splitters import RecursiveCharacterTextSplitter
4- from sqlalchemy import func , update
54
65from src .config .logger import get_logger
76from src .infrastructure .db import async_session_factory
8- from src .infrastructure .db .models import SourceRow
97from src .infrastructure .db .repository import Repository
108from src .ingestion .scrapers .html_scraper import scrape
119from src .retrieval .services import embedding_service
@@ -75,9 +73,7 @@ async def ingest_url(url: str) -> None:
7573 source_id = source .id ,
7674 )
7775
78- await session .execute (
79- update (SourceRow ).where (SourceRow .id == source .id ).values (last_synced_at = func .now ())
80- )
76+ await Repository .update_source_synced (session , source .id )
8177 await session .commit ()
8278
8379 log .info ("ingest_complete" , url = url , n_chunks = len (chunks ))
You can’t perform that action at this time.
0 commit comments