Skip to content

Commit

Permalink
Fixed realtime changes in helpdesk page
Browse files Browse the repository at this point in the history
  • Loading branch information
mellelieuwes committed Jul 4, 2024
1 parent a68d232 commit 48ae987
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/systems/assignment/_public.ex
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ defmodule Systems.Assignment.Public do
|> Repo.get(id)
end

def get_by_content_page(%Content.PageModel{} = page, preload \\ []) do
assignment_query(page)
|> Repo.one()
|> Repo.preload(preload)
end

def get_workflow!(id, preload \\ []) do
from(a in Workflow.Model, preload: ^preload)
|> Repo.get!(id)
Expand Down
11 changes: 11 additions & 0 deletions core/systems/assignment/_queries.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule Systems.Assignment.Queries do

alias Systems.Assignment
alias Systems.Account
alias Systems.Content
alias Systems.Project

def assignment_query() do
Expand All @@ -19,6 +20,16 @@ defmodule Systems.Assignment.Queries do
])
end

def assignment_query(%Content.PageModel{id: page_id}) do
build(assignment_query(), :assignment,
page_refs: [
page: [
id == ^page_id
]
]
)
end

def assignment_query(%Account.User{id: user_id}, :participant) do
build(assignment_query(), :assignment,
crew: [
Expand Down
19 changes: 19 additions & 0 deletions core/systems/assignment/_switch.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@ defmodule Systems.Assignment.Switch do
alias Systems.Crew
alias Systems.NextAction

@impl true
def intercept(
{:content_page, _} = signal,
%{content_page: content_page} = message
) do
if assignment =
Assignment.Public.get_by_content_page(
content_page,
Assignment.Model.preload_graph(:down)
) do
dispatch!(
{:assignment, signal},
Map.merge(message, %{assignment: assignment})
)
end

:ok
end

@impl true
def intercept(
{:project_item, :inserted} = signal,
Expand Down

0 comments on commit 48ae987

Please sign in to comment.