File tree Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,10 @@ defmodule Algora.Cloud do
41
41
call ( AlgoraCloud.JobLive , :offer , [ assigns ] )
42
42
end
43
43
44
+ def notify_match ( attrs ) do
45
+ call ( AlgoraCloud.Talent.Jobs.SendJobMatchEmail , :send , [ attrs ] )
46
+ end
47
+
44
48
def start do
45
49
call ( AlgoraCloud , :start , [ ] )
46
50
end
Original file line number Diff line number Diff line change @@ -52,17 +52,32 @@ defmodule Algora.Matches do
52
52
def upsert_job_match ( attrs ) do
53
53
case create_job_match ( attrs ) do
54
54
{ :ok , match } ->
55
- # Admin.enqueue_job_match_emails(1, user_id: attrs.user_id)
55
+ if confirmed? ( match ) do
56
+ Algora.Cloud . notify_match ( attrs )
57
+ end
58
+
56
59
{ :ok , match }
57
60
58
61
{ :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 ( )
62
+ match = Repo . get_by ( JobMatch , user_id: attrs . user_id , job_posting_id: attrs . job_posting_id )
63
+
64
+ case match |> change ( % { status: attrs . status } ) |> Repo . update ( ) do
65
+ { :ok , updated_match } = result ->
66
+ if not confirmed? ( match ) and confirmed? ( updated_match ) do
67
+ Algora.Cloud . notify_match ( attrs )
68
+ end
69
+
70
+ result
71
+
72
+ error ->
73
+ error
74
+ end
63
75
end
64
76
end
65
77
78
+ defp confirmed? ( % { status: status } ) when status in [ :approved , :highlighted ] , do: true
79
+ defp confirmed? ( _match ) , do: false
80
+
66
81
def fetch_job_matches ( job_posting_id ) do
67
82
job = Repo . get! ( JobPosting , job_posting_id )
68
83
You can’t perform that action at this time.
0 commit comments