From f1fba2dfb2dc0a429c7cf168807c6ddd1ee0fa53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Manuel=20G=C3=B3mez?= Date: Thu, 11 Jun 2026 23:10:26 +0200 Subject: [PATCH] Show git commit hash as version in Slack header Co-Authored-By: Claude Sonnet 4.6 --- slack_reporter.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/slack_reporter.py b/slack_reporter.py index 87f3477..da8e455 100644 --- a/slack_reporter.py +++ b/slack_reporter.py @@ -1,9 +1,21 @@ import json +import subprocess import requests import config from datetime import datetime, timedelta, date +def _git_version() -> str: + try: + return subprocess.check_output( + ["git", "rev-parse", "--short", "HEAD"], + stderr=subprocess.DEVNULL, + text=True, + ).strip() + except Exception: + return "unknown" + + ALERT_LOSS_EUR = 200 # pérdida absoluta > 200€ → alerta ALERT_MARGIN_PCT = -50 # margen % < -50% → alerta TOP_N = 5 # campañas a mostrar en rankings @@ -214,11 +226,12 @@ def build_and_send(collected: list, dry_run: bool, prev_month_metricas: dict = N # ── Construir bloques ───────────────────────────────────────────────────── mode = "🔵 DRY RUN" if dry_run else "⚡ PRODUCCIÓN" + version = _git_version() blocks = [ { "type": "header", - "text": {"type": "plain_text", "text": f"LEADS OPTIMIZER — {now.strftime('%d/%m/%Y %H:%M')} {mode}"}, + "text": {"type": "plain_text", "text": f"LEADS OPTIMIZER v{version} — {now.strftime('%d/%m/%Y %H:%M')} {mode}"}, }, { "type": "section",