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 1
1
defmodule Algora.Matches do
2
2
@ moduledoc false
3
3
4
+ import Ecto.Changeset
4
5
import Ecto.Query , warn: false
5
6
6
7
alias Algora.Jobs.JobPosting
7
8
alias Algora.Matches.JobMatch
8
9
alias Algora.Repo
9
10
11
+ require Logger
12
+
10
13
def list_job_matches ( opts \\ [ ] ) do
11
14
order_by_clause = opts [ :order_by ] || [ asc: :updated_at ]
12
15
@@ -46,6 +49,20 @@ defmodule Algora.Matches do
46
49
|> Repo . insert ( )
47
50
end
48
51
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
+
49
66
def fetch_job_matches ( job_posting_id ) do
50
67
job = Repo . get! ( JobPosting , job_posting_id )
51
68
You can’t perform that action at this time.
0 commit comments