From 794eeb9a71cdbf1f91de23653228c0e386a6bbac Mon Sep 17 00:00:00 2001 From: "Mauro Rosero P." Date: Wed, 12 Mar 2025 11:14:47 -0500 Subject: [PATCH] =?UTF-8?q?[IMPROVED]=20Refinar=20c=C3=A1lculo=20de=20prom?= =?UTF-8?q?edio=20para=20tarifas=20excesivas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Considerar solo tarifas que no exceden el umbral al calcular promedios - Añadir mensajes de log detallados sobre tarifas incluidas o excluidas - Eliminar verificación redundante de umbral en el cálculo del promedio - Mejorar la claridad de los mensajes sobre tarifas válidas utilizadas 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- bin/rate_update.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/rate_update.py b/bin/rate_update.py index 6c1298b..06f09bd 100755 --- a/bin/rate_update.py +++ b/bin/rate_update.py @@ -643,16 +643,20 @@ def update_rate_files(): content = f.read().strip() if content: other_rate = float(content) - same_type_rates.append(other_rate) + # Solo incluir tarifas que no excedan el umbral + if other_rate <= rate_threshold: + same_type_rates.append(other_rate) + logger.info(f"Considerando tarifa válida para promedio: {other_rate:.2f} de {other_region}") + else: + logger.info(f"Ignorando tarifa para promedio (excede umbral): {other_rate:.2f} de {other_region}") except (ValueError, FileNotFoundError): continue # Si encontramos tarifas del mismo tipo, calcular el promedio if same_type_rates: avg_rate = sum(same_type_rates) / len(same_type_rates) - # Asegurar que el promedio tampoco exceda el umbral - avg_rate = min(avg_rate, rate_threshold) - logger.warning(f"Tarifa {rate:.2f} supera el umbral de {rate_threshold}. Usando promedio de {len(same_type_rates)} tarifas: {avg_rate:.2f}") + # El promedio nunca excederá el umbral ya que solo incluimos tarifas válidas + logger.warning(f"Tarifa {rate:.2f} supera el umbral de {rate_threshold}. Usando promedio de {len(same_type_rates)} tarifas válidas: {avg_rate:.2f}") rate = round(avg_rate, 2) else: # Si no hay otras tarifas para calcular el promedio, usar un valor de fallback