feat(product-suite): refine history account filters

This commit is contained in:
chengma
2026-07-17 11:00:02 +08:00
parent 9f55dcd4f0
commit 098dc667b3
8 changed files with 195 additions and 31 deletions
+40 -1
View File
@@ -151,6 +151,13 @@ class ImageStudioHistoryRound:
is_legacy: bool
@dataclass(frozen=True)
class ImageStudioHistoryAccount:
"""One account alias retained by active product-suite history."""
account_alias: str
@dataclass(frozen=True)
class ImageStudioSuccessfulGenerationHistorySummary:
"""Successful persisted output summary for one active product project."""
@@ -1379,8 +1386,36 @@ def get_successful_generation_history_summary(project_id, path=None, conn=None):
)
def list_global_history_accounts(path=None, conn=None):
"""List account aliases retained by non-deleted product-suite history."""
sql = """
SELECT projects.account_alias AS account_alias
FROM image_studio_projects AS projects
WHERE projects.deleted_at IS NULL
AND TRIM(COALESCE(projects.account_alias, '')) <> ''
AND EXISTS (
SELECT 1
FROM image_studio_jobs AS jobs
WHERE jobs.project_id = projects.id
)
GROUP BY projects.account_alias
ORDER BY projects.account_alias COLLATE NOCASE ASC,
projects.account_alias ASC
"""
with _connection(conn, path) as database:
rows = database.execute(sql).fetchall()
return [
ImageStudioHistoryAccount(
account_alias=str(row["account_alias"] or ""),
)
for row in rows
]
def list_global_generation_rounds(
*,
account_alias=None,
account_query="",
item_query="",
project_id=None,
@@ -1411,8 +1446,12 @@ def list_global_generation_rounds(
params.append(int(project_id))
except (TypeError, ValueError) as exc:
raise db.DbError("当前商品项目无效") from exc
account_alias_text = str(account_alias or "").strip()
account_text = str(account_query or "").strip()
if account_text:
if account_alias_text:
clauses.append("projects.account_alias = ?")
params.append(account_alias_text)
if not account_alias_text and account_text:
pattern = "%%%s%%" % account_text
clauses.append(
"(projects.account_alias LIKE ? OR COALESCE(projects.account_name, '') LIKE ?)"