Collection management part 2 (#522)

* Plumb collection manager into librarian

* Test end-to-end
This commit is contained in:
cybermaggedon 2025-09-19 16:08:47 +01:00 committed by GitHub
parent d378db9370
commit fcd15d1833
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 617 additions and 434 deletions

View file

@ -654,7 +654,7 @@ class LibraryTableStore:
logger.error(f"Error updating collection: {e}")
raise
async def delete_collection_metadata(self, user, collection):
async def delete_collection(self, user, collection):
"""Delete collection metadata record"""
try:
await asyncio.get_event_loop().run_in_executor(
@ -683,3 +683,35 @@ class LibraryTableStore:
except Exception as e:
logger.error(f"Error getting collection: {e}")
raise
async def create_collection(self, user, collection, name=None, description=None, tags=None):
"""Create a new collection metadata record"""
try:
import datetime
now = datetime.datetime.now()
# Set defaults for optional parameters
name = name if name is not None else collection
description = description if description is not None else ""
tags = tags if tags is not None else set()
await asyncio.get_event_loop().run_in_executor(
None, self.cassandra.execute, self.insert_collection_stmt,
[user, collection, name, description, tags, now, now]
)
logger.info(f"Created collection {user}/{collection}")
# Return the created collection data
return {
"user": user,
"collection": collection,
"name": name,
"description": description,
"tags": list(tags) if isinstance(tags, set) else tags,
"created_at": now.isoformat(),
"updated_at": now.isoformat()
}
except Exception as e:
logger.error(f"Error creating collection: {e}")
raise