Update on 2025-08-12 15:41:50

This commit is contained in:
2025-08-12 15:41:50 +01:00
parent c74790b014
commit 63cf1c2dc6

View File

@@ -56,7 +56,7 @@ def build_monthly_rows(hops: Iterable[Hop], site_config: SiteConfig, distance_re
rows_by_month: Dict[str, List[Tuple[str, str, float, str, str, str, str, str]]] = defaultdict(list) rows_by_month: Dict[str, List[Tuple[str, str, float, str, str, str, str, str]]] = defaultdict(list)
for hop in hops: for hop in hops:
month_key = hop.date.strftime("%Y-%m") month_key = hop.date.strftime("%Y-%m") # Keep YYYY-MM for sheet naming
origin_site = site_config.by_canonical.get(hop.origin) origin_site = site_config.by_canonical.get(hop.origin)
dest_site = site_config.by_canonical.get(hop.destination) dest_site = site_config.by_canonical.get(hop.destination)
if origin_site is None or dest_site is None: if origin_site is None or dest_site is None:
@@ -72,7 +72,7 @@ def build_monthly_rows(hops: Iterable[Hop], site_config: SiteConfig, distance_re
purpose = f"Travel from {origin_site.label} to {dest_site.label} {dist:.1f}mi" purpose = f"Travel from {origin_site.label} to {dest_site.label} {dist:.1f}mi"
rows_by_month[month_key].append( rows_by_month[month_key].append(
( (
hop.date.isoformat(), hop.date.strftime("%d/%m/%Y"), # Change date format here
purpose, purpose,
dist, dist,
distance_resolver.vehicle_label if hasattr(distance_resolver, "vehicle_label") else "SH11 DRV (Own 1.6CC Diesel Car/Van)", distance_resolver.vehicle_label if hasattr(distance_resolver, "vehicle_label") else "SH11 DRV (Own 1.6CC Diesel Car/Van)",
@@ -82,6 +82,7 @@ def build_monthly_rows(hops: Iterable[Hop], site_config: SiteConfig, distance_re
"", "",
) )
) )
return rows_by_month return rows_by_month
@@ -119,4 +120,5 @@ def write_monthly_workbook(rows_by_month: Dict[str, List[Tuple[str, str, float,
ws.column_dimensions[column_letter].width = max_length + 2 ws.column_dimensions[column_letter].width = max_length + 2
# Ensure directory exists # Ensure directory exists
os.makedirs(os.path.dirname(output_path), exist_ok=True) os.makedirs(os.path.dirname(output_path), exist_ok=True)
wb.save(output_path) wb.save(output_path)