Skip to content

Commit 48706c3

Browse files
committed
feat: add job matches and system tags functionality
- Introduced a new `JobMatch` schema and migration to create the `job_matches` table, allowing for tracking job applications with user references and statuses. - Added a `system_tags` field to the `JobPosting` schema, enabling categorization of job postings with an array of strings. - Updated job listing logic to include `JobMatch` in the query for enhanced filtering and ordering capabilities.
1 parent 0311687 commit 48706c3

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

lib/algora/jobs/jobs.ex

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ defmodule Algora.Jobs do
1313
alias Algora.Repo
1414
alias Algora.Util
1515
alias AlgoraCloud.Interviews.JobInterview
16+
alias AlgoraCloud.Matches.JobMatch
1617

1718
require Logger
1819

@@ -23,10 +24,12 @@ defmodule Algora.Jobs do
2324
|> join(:inner, [j], u in User, on: u.id == j.user_id)
2425
|> maybe_filter_by_tech_stack(opts[:tech_stack])
2526
|> join(:left, [j], i in JobInterview, on: i.job_posting_id == j.id)
26-
|> group_by([j, u, i], [u.contract_signed, j.id, j.inserted_at])
27-
|> order_by([j, u, i],
27+
|> join(:left, [j], m in JobMatch, on: m.job_posting_id == j.id)
28+
|> group_by([j, u, i, m], [u.contract_signed, j.id, j.inserted_at])
29+
|> order_by([j, u, i, m],
2830
desc: u.contract_signed,
2931
desc_nulls_last: max(i.inserted_at),
32+
desc_nulls_last: max(m.inserted_at),
3033
desc: j.inserted_at
3134
)
3235
|> maybe_limit(opts[:limit])

lib/algora/jobs/schemas/job_posting.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ defmodule Algora.Jobs.JobPosting do
2222
field :regions, {:array, :string}, default: []
2323
field :compensation, :string
2424
field :seniority, :string
25+
field :system_tags, {:array, :string}, default: []
2526

2627
belongs_to :user, User, null: false
2728
has_many :interviews, AlgoraCloud.Interviews.JobInterview, foreign_key: :job_posting_id
29+
has_many :matches, AlgoraCloud.Matches.JobMatch, foreign_key: :job_posting_id
2830

2931
timestamps()
3032
end
@@ -46,7 +48,8 @@ defmodule Algora.Jobs.JobPosting do
4648
:compensation,
4749
:seniority,
4850
:countries,
49-
:regions
51+
:regions,
52+
:system_tags
5053
])
5154
|> generate_id()
5255
|> validate_required([:url, :company_name, :company_url, :email])
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
defmodule Algora.Repo.Migrations.CreateJobMatches do
2+
use Ecto.Migration
3+
4+
def change do
5+
create table(:job_matches) do
6+
add :user_id, references(:users, on_delete: :delete_all, type: :string), null: false
7+
8+
add :job_posting_id, references(:job_postings, on_delete: :delete_all, type: :string),
9+
null: false
10+
11+
add :status, :string, null: false, default: "pending"
12+
add :score, :decimal, precision: 5, scale: 2
13+
add :notes, :text
14+
15+
timestamps()
16+
end
17+
18+
create unique_index(:job_matches, [:user_id, :job_posting_id])
19+
create index(:job_matches, [:user_id])
20+
create index(:job_matches, [:job_posting_id])
21+
create index(:job_matches, [:status])
22+
end
23+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
defmodule Algora.Repo.Migrations.AddSystemTagsToJobPostings do
2+
use Ecto.Migration
3+
4+
def change do
5+
alter table(:job_postings) do
6+
add :system_tags, {:array, :string}, default: []
7+
end
8+
end
9+
end

0 commit comments

Comments
 (0)