RatioPBC / epi-viewpoint

Epi Viewpoint is a focused, simple tool that enables case investigation and contact tracing teams to manage cases and contacts and keep track of congregate settings where outbreak clusters have occurred.
Apache License 2.0
8 stars 1 forks source link

Isolation monitoring tab fails with "My assignments only" checked #7

Closed patmaddox closed 2 years ago

patmaddox commented 2 years ago

viewpoint-filter-bug

  1. Assign a person to a user
  2. Activate "My assignments only"
  3. Choose "Isolation monitoring" tab

Result: The tab takes a few seconds to load, and de-activates "My assignments only"

On the backend, an Elixir process crashes with:

[error] GenServer #PID<0.1908.0> terminating
** (Ecto.QueryError) invalid query has specified more bindings than bindings available in `where` (look for `unknown_binding!` in the printed query below) in query:

from c0 in Epicenter.Cases.CaseInvestigation,
  join: p1 in Epicenter.Cases.Person,
  on: p1.id == c0.person_id,
  where: is_nil(p1.archived_at) and c0.interview_status == "completed" and c0.isolation_monitoring_status in ["pending", "ongoing"],
  where: unknown_binding_2!.id == ^"67392319-5ee1-4693-a3c1-a26001c8028b",
  order_by: [desc: c0.isolation_monitoring_status, asc: c0.isolation_monitoring_ends_on, desc: c0.interview_completed_at, desc: p1.seq],
  select: c0

    (elixir 1.11.3) lib/enum.ex:2193: Enum."-reduce/3-lists^foldl/2-0-"/3
    (elixir 1.11.3) lib/enum.ex:1533: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (elixir 1.11.3) lib/enum.ex:1533: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (elixir 1.11.3) lib/enum.ex:2193: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ecto 3.7.1) lib/ecto/repo/queryable.ex:203: Ecto.Repo.Queryable.execute/4
    (ecto 3.7.1) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3
    (epicenter 0.1.0) lib/epicenter/auditing_repo.ex:9: Epicenter.AuditingRepo.all/2
    (epicenter 0.1.0) lib/epicenter_web/live/people_live.ex:168: EpicenterWeb.PeopleLive.load_and_assign_case_investigations/1
Last message: %Phoenix.Socket.Message{event: "live_patch", join_ref: "4", payload: %{"url" => "http://localhost:4000/people?filter=isolation_monitoring"}, ref: "8", topic: "lv:phx-FsCxj7bIdjhX4DrB"}
State: %{components: {%{1 => {EpicenterWeb.PeopleFilter, "people filter", %{__changed__: %{}, display_people_assigned_to_me: true, filter: :ongoing_interview, flash: %{}, id: "people filter", myself: %Phoenix.LiveComponent.CID{cid: 1}, on_toggle_assigned_to_me: #Function<9.119671958/0 in EpicenterWeb.PeopleLive."-fun.on_toggle_assigned_to_me/0-">}, %{__changed__: %{}, root_view: EpicenterWeb.PeopleLive}, {117377789967003153379326142889720130031, %{4 => {313290207818683109671330501276579846330, %{}}, 5 => {91106593058113106934729846810084644984, %{1 => {1542194025956032883977558056248238076, %{}}}}}}}}, %{EpicenterWeb.PeopleFilter => %{"people filter" => 1}}, 2}, join_ref: "4", serializer: Phoenix.Socket.V2.JSONSerializer, socket: #Phoenix.LiveView.Socket<assigns: %{__changed__: %{}, body_class: "body-background-none", case_count: 0, case_investigations: [], current_date: ~D[2021-12-14], current_user: #Epicenter.Accounts.User<__meta__: #Ecto.Schema.Metadata<:loaded, "users">, ...>, display_import_button: true, ...}, endpoint: EpicenterWeb.Endpoint, id: "phx-FsCxj7bIdjhX4DrB", parent_pid: nil, root_pid: #PID<0.1908.0>, router: EpicenterWeb.Router, transport_pid: #PID<0.1902.0>, view: EpicenterWeb.PeopleLive, ...>, topic: "lv:phx-FsCxj7bIdjhX4DrB", upload_names: %{}, upload_pids: %{}}