Commit 9f38d87e authored by Peter van der meulen's avatar Peter van der meulen

Compare times in day forecast more properly

parent 457c2dd6
Pipeline #147 passed with stage
in 1 minute and 36 seconds
......@@ -25,7 +25,7 @@ defmodule AuroraBot.DayForecast do
defp in_timezone_and_strong?(record) do
time = record.datetime |> Timex.to_datetime() |> DateTime.to_time()
time >= ~T[18:00:00] && record.kp >= 5
Timex.compare(time, ~T[18:00:00]) >= 0 && record.kp >= 5
end
defp group_per_day(records) do
......
......@@ -23,6 +23,12 @@ defmodule DayForecastSpec do
expected2 = %DayForecast{datetime: ~N[2018-11-17 21:00:00], kp: 6}
expect DayForecast.get!() |> to(eq [expected1, expected2])
end
it "returns no records when times are before 18:00" do
mock_noaa_request(5, 6, "2018-11-16 17:00:00", "2018-11-17 16:00:00")
expect DayForecast.get!() |> to(eq [])
end
end
def mock_noaa_request(kp1, kp2, time_tag1, time_tag2) do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment