From 05967fff6c7cd0379dbafba274f908695867b989 Mon Sep 17 00:00:00 2001 From: Antoine Augusti Date: Fri, 15 Nov 2024 16:35:56 +0100 Subject: [PATCH] =?UTF-8?q?StatsHandler=20:=20g=C3=A8re=20cas=20nil=20pour?= =?UTF-8?q?=20vehicle=5Ftypes=20en=20GBFS=20(#4316)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/transport/lib/transport/stats_handler.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/transport/lib/transport/stats_handler.ex b/apps/transport/lib/transport/stats_handler.ex index 9265ddcbb4..72a87236cf 100644 --- a/apps/transport/lib/transport/stats_handler.ex +++ b/apps/transport/lib/transport/stats_handler.ex @@ -141,10 +141,12 @@ defmodule Transport.StatsHandler do @doc """ iex> gbfs_vehicle_types_stats([%{"vehicle_types" => ["bicycle", "scooter"]}, %{"vehicle_types" => ["bicycle"]}]) %{gbfs_vehicle_type_bicycle_count: 2, gbfs_vehicle_type_scooter_count: 1} + iex> gbfs_vehicle_types_stats([%{"vehicle_types" => ["bicycle"]}, %{"vehicle_types" => nil}]) + %{gbfs_vehicle_type_bicycle_count: 1} """ def gbfs_vehicle_types_stats(rows) do rows - |> Enum.flat_map(& &1["vehicle_types"]) + |> Enum.flat_map(&(&1["vehicle_types"] || [])) |> Enum.frequencies() |> Map.new(fn {k, v} -> {String.to_atom("gbfs_vehicle_type_#{k}_count"), v} end) end