diff --git a/ops/hub-core/events_digest.py b/ops/hub-core/events_digest.py index 3de7665..1e6fe35 100644 --- a/ops/hub-core/events_digest.py +++ b/ops/hub-core/events_digest.py @@ -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}")