diff --git a/run.py b/run.py index 23f80e2..df95ab0 100644 --- a/run.py +++ b/run.py @@ -400,6 +400,8 @@ def run(): if cambio_mes: # Ayer pertenece al mes anterior: redirigir escritura al GACampaignMes correcto prev_map = at.get_gcm_id_map_for_month(ayer.month, ayer.year) + redirected = [] + omitidos = [] for u in metricas_updates: gid = next( (item["campaign"]["google_campaign_id"] @@ -408,6 +410,13 @@ def run(): ) if gid and gid in prev_map: u["airtable_id"] = prev_map[gid] + redirected.append(u) + else: + omitidos.append(gid) + metricas_updates = redirected + if omitidos: + print(f" ⚠️ {len(omitidos)} campañas sin GACampaignMes en {ayer.month}/{ayer.year}, " + f"MetricasDiarias del día anterior omitido para no contaminar el mes nuevo: {omitidos}") at.batch_update_metricas_diarias(metricas_updates) print(" ✓ MetricasDiarias actualizado.") diff --git a/slack_reporter.py b/slack_reporter.py index 7128519..66a4efc 100644 --- a/slack_reporter.py +++ b/slack_reporter.py @@ -73,8 +73,9 @@ def _trunc(text: str, limit: int = 2950) -> str: def _fmt_eur(v: float) -> str: - sign = "+" if v > 0 else "" - return f"{sign}{v:,.0f}€".replace(",", ".") + v_int = round(v) + sign = "+" if v_int > 0 else "" + return f"{sign}{v_int:,.0f}€".replace(",", ".") def _curso(name: str, max_len: int = 40) -> str: @@ -196,7 +197,8 @@ def build_and_send(collected: list, dry_run: bool, prev_month_metricas: dict = N return f"{v:,.0f}€".replace(",", ".") def _marg(v: float) -> str: - return ("+" if v >= 0 else "") + f"{v:,.0f}€".replace(",", ".") + v_int = round(v) + return ("+" if v_int >= 0 else "") + f"{v_int:,.0f}€".replace(",", ".") def _pct(v: float) -> str: return ("+" if v >= 0 else "") + f"{v:.1f}%"