omni: веб-панель (serve + /api), дайджест, arxiv API-fallback, HF trending unwrap
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user