omni: веб-панель (serve + /api), дайджест, arxiv API-fallback, HF trending unwrap

This commit is contained in:
dev
2026-10-25 19:11:52 +03:00
parent c4d188520f
commit e1368f2a46
6 changed files with 446 additions and 2 deletions

View File

@@ -131,6 +131,25 @@ def search(q, limit=20):
"ORDER BY score DESC LIMIT ?", (like, like, limit)).fetchall()
def browse(category=None, q="", limit=60, offset=0):
"""Список записей для веб-панели: фильтр по категории источника и подстроке."""
sql = ("SELECT provider,kind,source,title,text,author,published,score,price,currency,url "
"FROM items WHERE 1=1 ")
args = []
if category and category != "all":
sql += "AND source=? "
args.append(category)
if q:
sql += "AND (title LIKE ? OR text LIKE ?) "
args += [f"%{q}%", f"%{q}%"]
sql += "ORDER BY score DESC, id DESC LIMIT ? OFFSET ?"
args += [limit, offset]
with conn() as c:
rows = c.execute(sql, args).fetchall()
keys = ("provider", "kind", "source", "title", "text", "author", "published", "score", "price", "currency", "url")
return [dict(zip(keys, r)) for r in rows]
def stats():
with conn() as c:
total = c.execute("SELECT COUNT(*) FROM items").fetchone()[0]