Skip to content

Commit

Permalink
fix: add function for detours without virtual estimated_duration popu…
Browse files Browse the repository at this point in the history
…lation
  • Loading branch information
hannahpurcell committed Feb 12, 2025
1 parent 75463e8 commit f9fc718
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/skate/detours/detours.ex
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,23 @@ defmodule Skate.Detours.Detours do
activated_at: activated_at,
estimated_duration: estimated_duration
} = db_detour
) when estimated_duration != nil do
details = DetailedDetour.from(:active, db_detour)

details &&
%ActivatedDetourDetails{
activated_at: activated_at,
estimated_duration: estimated_duration,
details: details
}
end

def db_detour_to_detour(
:active,
%{
activated_at: activated_at,
state: %{"context" => %{"selectedDuration" => estimated_duration}}
} = db_detour
) do
details = DetailedDetour.from(:active, db_detour)

Expand All @@ -122,6 +139,8 @@ defmodule Skate.Detours.Detours do
nil
end

# Missed this, but this description no longer fits

@doc """
Takes a `Skate.Detours.Db.Detour` struct and a `Skate.Settings.Db.User` id
and returns a `t:Detour.status/0` based on the state of the detour.
Expand Down

0 comments on commit f9fc718

Please sign in to comment.