From 0165a5f023efe3f79528b1552e115b5a08e84a80 Mon Sep 17 00:00:00 2001 From: Ryan Michael Date: Mon, 29 Jan 2024 15:14:58 -0500 Subject: [PATCH] Back out collection name --- dewy/documents/models.py | 3 --- dewy/documents/router.py | 12 +----------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/dewy/documents/models.py b/dewy/documents/models.py index 539b73e..1c81ac3 100644 --- a/dewy/documents/models.py +++ b/dewy/documents/models.py @@ -5,9 +5,6 @@ class CreateRequest(BaseModel): - collection: Optional[str] = None - """The name of the collection the document should be added to. Either `collection` or `collection_id` must be provided""" - collection_id: Optional[int] = None """The id of the collection the document should be added to. Either `collection` or `collection_id` must be provided""" diff --git a/dewy/documents/router.py b/dewy/documents/router.py index c46fa46..8e01e45 100644 --- a/dewy/documents/router.py +++ b/dewy/documents/router.py @@ -25,17 +25,7 @@ async def add_document( ) -> Document: """Add a document.""" - collection_id = req.collection_id async with pg_pool.acquire() as conn: - if collection_id is None: - collection_id = await conn.fetchval( - """ - SELECT collection_id - FROM document - WHERE name = $1 - """, - req.collection - ) row = None row = await conn.fetchrow( """ @@ -43,7 +33,7 @@ async def add_document( VALUES ($1, $2, 'pending') RETURNING id, collection_id, url, ingest_state, ingest_error """, - collection_id, + req.collection_id, req.url, )