diff --git a/lib/planner/tasks.ex b/lib/planner/tasks.ex index a92dd6a..a587998 100644 --- a/lib/planner/tasks.ex +++ b/lib/planner/tasks.ex @@ -32,13 +32,13 @@ defmodule Planner.Tasks do |> Repo.preload(:plans) end - def list_unfinished_tasks_by_plan_id(plan_id) do + def list_unfinished_tasks_by_plan_id(plan_id, task_id \\ nil) do q = Ecto.Query.from( t in Task, join: pd in PlanDetail, on: t.id == pd.task_id, - where: pd.plan_id == ^plan_id and is_nil(t.finished_at), + where: (pd.plan_id == ^plan_id and is_nil(t.finished_at)) or t.id == ^task_id, order_by: [desc: t.updated_at] ) diff --git a/lib/planner_web/live/tasks_components.ex b/lib/planner_web/live/tasks_components.ex index 635a014..41bf8e6 100644 --- a/lib/planner_web/live/tasks_components.ex +++ b/lib/planner_web/live/tasks_components.ex @@ -74,13 +74,18 @@ defmodule TaskComponent do