diff --git a/lib/dotcom_web/controllers/trip_plan/feedback_csv.ex b/lib/dotcom_web/controllers/trip_plan/feedback_csv.ex index 1b0ba5b342..07b7b3bdd5 100644 --- a/lib/dotcom_web/controllers/trip_plan/feedback_csv.ex +++ b/lib/dotcom_web/controllers/trip_plan/feedback_csv.ex @@ -3,6 +3,8 @@ defmodule DotcomWeb.TripPlan.FeedbackCSV do Handle formatting feedback into a spreadsheet-friendly format. """ + require Logger + alias TripPlan.PersonalDetail.Step @headers [ @@ -132,7 +134,7 @@ defmodule DotcomWeb.TripPlan.FeedbackCSV do "#{place_description(from)} to #{place_description(to)} via #{mode_description(mode)}" end - defp mode_description(%{"route_id" => route_id, "trip_id" => trip_id}), + defp mode_description(%{"route" => %{"id" => route_id}, "trip_id" => trip_id}), do: route_id <> " route on trip " <> trip_id defp mode_description(%{"steps" => steps, "distance" => distance}) do @@ -153,4 +155,13 @@ defmodule DotcomWeb.TripPlan.FeedbackCSV do "walking #{distance} meters:\n\t#{step_description}" end + + defp mode_description(mode) do + trip_id = Map.get(mode, "trip_id") + type = Map.get(mode, "mode") + + Logger.error("#{__MODULE__} error=unknown_mode trip_id=#{trip_id} type=#{type}") + + "unknown" + end end diff --git a/test/dotcom_web/controllers/trip_plan/feedback_csv_test.exs b/test/dotcom_web/controllers/trip_plan/feedback_csv_test.exs index 5dd52caf59..744b91aa3e 100644 --- a/test/dotcom_web/controllers/trip_plan/feedback_csv_test.exs +++ b/test/dotcom_web/controllers/trip_plan/feedback_csv_test.exs @@ -106,7 +106,9 @@ defmodule DotcomWeb.TripPlan.FeedbackCSVTest do }, "mode" => %{ "trip_id" => "60166270", - "route_id" => "4", + "route" => %{ + "id" => "4" + }, "intermediate_stop_ids" => [ "233", "234", @@ -317,7 +319,9 @@ defmodule DotcomWeb.TripPlan.FeedbackCSVTest do }, "mode" => %{ "trip_id" => "60564830", - "route_id" => "Green-D", + "route" => %{ + "id" => "Green-D" + }, "intermediate_stop_ids" => [ "70204", "70202" @@ -376,7 +380,9 @@ defmodule DotcomWeb.TripPlan.FeedbackCSVTest do }, "mode" => %{ "trip_id" => "60392520", - "route_id" => "Red", + "route" => %{ + "id" => "Red" + }, "intermediate_stop_ids" => [ "70077" ] @@ -405,7 +411,9 @@ defmodule DotcomWeb.TripPlan.FeedbackCSVTest do }, "mode" => %{ "trip_id" => "60455437", - "route_id" => "Orange", + "route" => %{ + "id" => "Orange" + }, "intermediate_stop_ids" => [ "70024", "70022" @@ -470,7 +478,9 @@ defmodule DotcomWeb.TripPlan.FeedbackCSVTest do }, "mode" => %{ "trip_id" => "60392519", - "route_id" => "Red", + "route" => %{ + "id" => "Red" + }, "intermediate_stop_ids" => [] }, "from" => %{