Skip to content

Commit c74bac7

Browse files
committed
feat: extend job match status enum
- Added `update_job_match_status` function to update the status of a job match by its ID. - Updated `JobMatch` schema to include new status values: `:discarded`, `:approved`, and `:highlighted`.
1 parent 29c5910 commit c74bac7

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/algora/matches/matches.ex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ defmodule Algora.Matches do
9595
|> Repo.update()
9696
end
9797

98+
def update_job_match_status(match_id, status) do
99+
case Repo.get(JobMatch, match_id) do
100+
nil -> {:error, :not_found}
101+
job_match -> update_job_match(job_match, %{status: status})
102+
end
103+
end
104+
98105
def delete_job_match(%JobMatch{} = job_match) do
99106
Repo.delete(job_match)
100107
end

lib/algora/matches/schemas/job_match.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule Algora.Matches.JobMatch do
55
import Ecto.Changeset
66

77
typed_schema "job_matches" do
8-
field :status, Ecto.Enum, values: [:pending, :accepted, :rejected], default: :pending
8+
field :status, Ecto.Enum, values: [:pending, :discarded, :approved, :highlighted], default: :pending
99
field :score, :decimal
1010
field :notes, :string
1111

@@ -19,7 +19,7 @@ defmodule Algora.Matches.JobMatch do
1919
job_match
2020
|> cast(attrs, [:user_id, :job_posting_id, :status, :score, :notes])
2121
|> validate_required([:user_id, :job_posting_id])
22-
|> validate_inclusion(:status, [:pending, :accepted, :rejected])
22+
|> validate_inclusion(:status, [:pending, :discarded, :approved, :highlighted])
2323
|> foreign_key_constraint(:user_id)
2424
|> foreign_key_constraint(:job_posting_id)
2525
|> unique_constraint([:user_id, :job_posting_id])

0 commit comments

Comments
 (0)