File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 11defmodule Algora.Matches do
22 @ moduledoc false
33
4+ import Ecto.Changeset
45 import Ecto.Query , warn: false
56
67 alias Algora.Jobs.JobPosting
78 alias Algora.Matches.JobMatch
89 alias Algora.Repo
910
11+ require Logger
12+
1013 def list_job_matches ( opts \\ [ ] ) do
1114 order_by_clause = opts [ :order_by ] || [ asc: :updated_at ]
1215
@@ -46,6 +49,20 @@ defmodule Algora.Matches do
4649 |> Repo . insert ( )
4750 end
4851
52+ def upsert_job_match ( attrs ) do
53+ case create_job_match ( attrs ) do
54+ { :ok , match } ->
55+ Admin . enqueue_job_match_emails ( 1 , user_id: attrs . user_id )
56+ { :ok , match }
57+
58+ { :error , _changeset } ->
59+ JobMatch
60+ |> Repo . get_by ( user_id: attrs . user_id , job_posting_id: attrs . job_posting_id )
61+ |> change ( % { status: attrs . status } )
62+ |> Repo . update ( )
63+ end
64+ end
65+
4966 def fetch_job_matches ( job_posting_id ) do
5067 job = Repo . get! ( JobPosting , job_posting_id )
5168
You can’t perform that action at this time.
0 commit comments