Keep generated template previews out of photo selection
This commit is contained in:
@@ -3,7 +3,7 @@ import os
|
||||
import re
|
||||
from contextlib import asynccontextmanager
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from typing import Any, Literal
|
||||
from uuid import uuid4
|
||||
|
||||
from fastapi import Depends, FastAPI, File, Form, Header, Query, Request, UploadFile
|
||||
@@ -479,12 +479,17 @@ def create_app(settings=None, start_worker=True):
|
||||
tags=["Images"],
|
||||
dependencies=[Depends(require("images:read"))],
|
||||
)
|
||||
def list_assets(limit: int = Query(default=100, ge=1, le=200)):
|
||||
def list_assets(
|
||||
limit: int = Query(default=100, ge=1, le=200),
|
||||
source: Literal["all", "uploaded", "generated"] = "all",
|
||||
):
|
||||
return [
|
||||
assets.info(r["id"])
|
||||
for r in db.all(
|
||||
"SELECT id FROM assets WHERE kind!='cache' ORDER BY created_at DESC LIMIT ?",
|
||||
(limit,),
|
||||
"SELECT id FROM assets WHERE kind!='cache' AND "
|
||||
"(?='all' OR (?='uploaded' AND kind='images') OR (?='generated' AND kind='generated')) "
|
||||
"ORDER BY created_at DESC LIMIT ?",
|
||||
(source, source, source, limit),
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user