fix(api): support asset library lookup for media guards
This commit is contained in:
@@ -8,6 +8,22 @@ class SQLAlchemyAssetLibraryRepository:
|
||||
def __init__(self, session: Session):
|
||||
self.session = session
|
||||
|
||||
def get(self, library_id: str) -> AssetLibrary | None:
|
||||
model = self.session.query(AssetLibraryModel).filter(AssetLibraryModel.id == library_id).first()
|
||||
if model is None:
|
||||
return None
|
||||
return AssetLibrary(
|
||||
id=model.id,
|
||||
workspace_id=model.workspace_id,
|
||||
project_id=model.project_id,
|
||||
name=model.name,
|
||||
kind=AssetLibraryKind(model.kind),
|
||||
asset_count=int(model.asset_count or 0),
|
||||
total_size=int(model.total_size or 0),
|
||||
created_at=model.created_at,
|
||||
updated_at=model.updated_at,
|
||||
)
|
||||
|
||||
def list_by_project(self, project_id: str, kind: AssetLibraryKind | None = None) -> list[AssetLibrary]:
|
||||
query = self.session.query(AssetLibraryModel).filter(AssetLibraryModel.project_id == project_id)
|
||||
if kind is not None:
|
||||
|
||||
Reference in New Issue
Block a user