diff --git a/lib/osuuspuutarha/harvest.ex b/lib/osuuspuutarha/harvest.ex index 959e438..c25795a 100644 --- a/lib/osuuspuutarha/harvest.ex +++ b/lib/osuuspuutarha/harvest.ex @@ -21,6 +21,10 @@ defmodule Osuuspuutarha.Harvest do Repo.all(Yield) end + def get_sorted_by_date do + Repo.all(Yield |> order_by({:desc, :date})) + end + @doc """ Gets a single yield. diff --git a/lib/osuuspuutarha_web/live/yield_live/index.ex b/lib/osuuspuutarha_web/live/yield_live/index.ex index 251331d..bd5c056 100644 --- a/lib/osuuspuutarha_web/live/yield_live/index.ex +++ b/lib/osuuspuutarha_web/live/yield_live/index.ex @@ -41,6 +41,6 @@ defmodule OsuuspuutarhaWeb.YieldLive.Index do end defp list_yields do - Harvest.list_yields() + Harvest.get_sorted_by_date() end end