From 2d1dd14e45e83efd7a57d8e8efbaefcaeaa8a76f Mon Sep 17 00:00:00 2001 From: OliverGiertz Date: Thu, 9 Apr 2026 07:02:03 +0000 Subject: [PATCH] fix(pipeline): send individual Telegram notifications for quality gate rejections MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add individual Telegram message when an article is rejected by quality gate (too short raw content or rewritten text), so users see each rejection in real time instead of only in the bulk summary - Add quality_gate_rejected counter to PipelineStats and result dict - Show quality gate rejections separately in pipeline-done summary (✂️ Qualitätsprüfung: N) distinct from score-based rejections Co-Authored-By: Claude Sonnet 4.6 --- backend/app/pipeline.py | 15 ++++++++++++++- backend/app/telegram_bot.py | 5 ++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/backend/app/pipeline.py b/backend/app/pipeline.py index 9cd9059..1ae1ff6 100644 --- a/backend/app/pipeline.py +++ b/backend/app/pipeline.py @@ -43,6 +43,7 @@ class PipelineStats: processed: int = 0 drafts_created: int = 0 rejected: int = 0 + quality_gate_rejected: int = 0 warnings: int = 0 errors: int = 0 no_image: int = 0 @@ -261,6 +262,7 @@ def run_auto_pipeline(trigger: str = "auto") -> dict[str, Any]: "processed": stats.processed, "drafts_created": stats.drafts_created, "rejected": stats.rejected, + "quality_gate_rejected": stats.quality_gate_rejected, "no_image": stats.no_image, "warnings": stats.warnings, "errors": stats.errors, @@ -372,8 +374,19 @@ def _process_article(article: dict[str, Any], stats: PipelineStats, settings: An # Release the reserved slot so it's available for the next article from .scheduler import release_publish_slot release_publish_slot(article_id) - stats.rejected_articles.append(get_article_by_id(article_id) or {}) + stats.quality_gate_rejected += 1 logger.info("Artikel #%d wegen Qualitätsprüfung abgelehnt: %s", article_id, exc) + # Individual Telegram notification for quality gate rejection + try: + title = (article.get("title") or "Ohne Titel")[:80] + tg.send_message( + f"✂️ Qualitätsprüfung nicht bestanden\n" + f"📰 {title}\n" + f"💯 Score: {score}/100\n" + f"⚠️ {exc}" + ) + except Exception as tg_exc: + logger.warning("Telegram QG-Benachrichtigung für #%d fehlgeschlagen: %s", article_id, tg_exc) except Exception as exc: logger.error("Draft-Erstellung für #%d fehlgeschlagen: %s", article_id, exc) diff --git a/backend/app/telegram_bot.py b/backend/app/telegram_bot.py index c92b009..880a49d 100644 --- a/backend/app/telegram_bot.py +++ b/backend/app/telegram_bot.py @@ -289,6 +289,7 @@ def notify_pipeline_done(stats: dict[str, Any]) -> None: processed = stats.get("processed", 0) drafts = stats.get("drafts_created", 0) rejected = stats.get("rejected", 0) + quality_gate_rejected = stats.get("quality_gate_rejected", 0) no_image = stats.get("no_image", 0) warnings = stats.get("warnings", 0) errors = stats.get("errors", 0) @@ -300,7 +301,9 @@ def notify_pipeline_done(stats: dict[str, Any]) -> None: f"📝 Drafts erstellt: {drafts}", ] if rejected: - lines.append(f"🚫 Abgelehnt: {rejected}") + lines.append(f"🚫 Abgelehnt (Score): {rejected}") + if quality_gate_rejected: + lines.append(f"✂️ Qualitätsprüfung: {quality_gate_rejected}") if no_image: lines.append(f"🖼️ Kein Bild: {no_image}") if warnings: