From 4581a5dbf22b2b053eba9d70902511535e4e45cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20N=C3=BDvlt?= Date: Fri, 9 Aug 2024 01:55:47 +0200 Subject: [PATCH] Fix --- lib/chore_tracker/accounts.ex | 4 ---- lib/chore_tracker/chores.ex | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/chore_tracker/accounts.ex b/lib/chore_tracker/accounts.ex index ed4b6ca..6c86c7f 100644 --- a/lib/chore_tracker/accounts.ex +++ b/lib/chore_tracker/accounts.ex @@ -18,10 +18,6 @@ defmodule ChoreTracker.Accounts do Repo.all(from user in User, where: user.id in ^ids) end - def get_user!(id) do - Repo.get!(User, id) - end - ## Database getters @doc """ diff --git a/lib/chore_tracker/chores.ex b/lib/chore_tracker/chores.ex index d511acb..db539ef 100644 --- a/lib/chore_tracker/chores.ex +++ b/lib/chore_tracker/chores.ex @@ -141,9 +141,9 @@ defmodule ChoreTracker.Chores do """ def get_chore_log!(id), do: Repo.get!(ChoreLog, id) - def get_last_log_for_assignee(%User{} = user) do + def get_last_chore_log_for_assignee(%Chore{} = chore, %User{} = user) do from(log in ChoreLog, - where: log.user_id == ^user.id, + where: log.chore_id == ^chore.id and log.user_id == ^user.id, order_by: [desc: :inserted_at], limit: 1 ) @@ -327,7 +327,7 @@ defmodule ChoreTracker.Chores do def next_chore_assignee(%Chore{} = chore) do chore.assignees - |> Enum.map(&{&1, get_last_log_for_assignee(&1)}) + |> Enum.map(&{&1, get_last_chore_log_for_assignee(chore, &1)}) |> Enum.sort_by( fn {_assignee, log} -> case log do