Fix
This commit is contained in:
parent
86f477c829
commit
4581a5dbf2
2 changed files with 3 additions and 7 deletions
|
@ -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 """
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue