Дайджест показывает «что есть» из инвентаризации
Утренняя сводка дополнена блоком из последней инвентаризации: медиа, музыка, книги, фото, документы. Теперь одно сообщение отвечает и «что произошло», и «что у нас есть». Проверено: дайджест отправился, блоки событий и заметного на месте.
This commit is contained in:
1 parent
cff44ce617
commit
c8cb797071
1 file changed
+24
@@ -54,6 +54,12 @@ def main():
|
||||
cur.execute("""select count(*) from actions where at > now() - interval '24 hours'""")
|
||||
actions = cur.fetchone()[0]
|
||||
|
||||
cur.execute("""select payload from data_docs
|
||||
where collection = 'inventory'
|
||||
order by updated_at desc limit 1""")
|
||||
inv_row = cur.fetchone()
|
||||
inventory_row = inv_row[0] if inv_row else None
|
||||
|
||||
cur.execute("""select source, type, entity->>'title' from events
|
||||
where at > now() - interval '24 hours'
|
||||
and type in ('media.imported','media.requested','service.alert','document.added','book.added')
|
||||
@@ -73,6 +79,24 @@ def main():
|
||||
lines.append("\n**Заметное**")
|
||||
for src, typ, title in notable:
|
||||
lines.append(f"• {title or '—'} ({typ}, {src})")
|
||||
if inventory_row:
|
||||
try:
|
||||
inv = inventory_row if isinstance(inventory_row, dict) else json.loads(inventory_row)
|
||||
jf = inv.get("jellyfin") or {}
|
||||
nv = inv.get("navidrome") or {}
|
||||
cb = inv.get("calibre") or {}
|
||||
im = inv.get("immich") or {}
|
||||
pl = inv.get("paperless") or {}
|
||||
lines.append("")
|
||||
lines.append("**Что есть**")
|
||||
lines.append(f"• Медиа: {jf.get('Movie')} фильмов, {jf.get('Series')} сериалов, "
|
||||
f"{jf.get('Episode')} серий")
|
||||
lines.append(f"• Музыка: {nv.get('albums')} альбомов, {nv.get('tracks')} треков")
|
||||
lines.append(f"• Книги: {cb.get('books')} · Фото: {im.get('assets')} · "
|
||||
f"Документы: {pl.get('documents')}")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
lines.append("")
|
||||
lines.append(f"Карточек: {entities} · открытых проблем: {open_problems} · действий: {actions}")
|
||||
|
||||
|
||||
Reference in new issue
Block a user