File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -47,8 +47,19 @@ defmodule Algora.Matches do
47
47
|> Enum . concat ( job . countries )
48
48
|> Enum . uniq ( )
49
49
50
+ existing_matches =
51
+ Repo . all (
52
+ from ( m in JobMatch ,
53
+ where: m . job_posting_id == ^ job_posting_id ,
54
+ where: m . status in [ :highlighted , :approved ]
55
+ )
56
+ )
57
+
58
+ existing_user_ids = Enum . map ( existing_matches , & & 1 . user_id )
59
+
50
60
[
51
- limit: 3 ,
61
+ limit: 6 - length ( existing_matches ) ,
62
+ ids_not: existing_user_ids ,
52
63
tech_stack: job . tech_stack ,
53
64
has_min_compensation: true ,
54
65
system_tags: job . system_tags ,
@@ -79,7 +90,12 @@ defmodule Algora.Matches do
79
90
80
91
Repo . transact ( fn ->
81
92
# Delete existing matches for this job posting
82
- Repo . delete_all ( from ( m in JobMatch , where: m . job_posting_id == ^ job_posting_id ) )
93
+ Repo . delete_all (
94
+ from ( m in JobMatch ,
95
+ where: m . job_posting_id == ^ job_posting_id ,
96
+ where: m . status not in [ :highlighted , :approved ]
97
+ )
98
+ )
83
99
84
100
# Insert new matches
85
101
case Repo . insert_all ( JobMatch , matches , on_conflict: :nothing ) do
You can’t perform that action at this time.
0 commit comments