Skip to content

Commit 99b80cc

Browse files
committed
add new indexes and columns
1 parent cc741a9 commit 99b80cc

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

lib/algora/accounts/schemas/user.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ defmodule Algora.Accounts.User do
6060
field :last_dm_date, :utc_datetime_usec
6161
field :candidate_notes, :string
6262
field :dm_thread_url, :string
63+
field :contribution_scores, :map, default: %{}
6364

6465
field :seeking_bounties, :boolean, default: false
6566
field :seeking_contracts, :boolean, default: false
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
defmodule Algora.Repo.Migrations.AddUsersPipelineCompositeIndex do
2+
use Ecto.Migration
3+
4+
def change do
5+
create index(
6+
:users,
7+
[
8+
:type,
9+
:country,
10+
:open_to_new_role,
11+
:provider_login,
12+
:opt_out_algora,
13+
:last_job_match_email_at
14+
],
15+
where:
16+
"type = 'individual' AND provider_login IS NOT NULL AND opt_out_algora = false AND open_to_new_role = true AND country IN ('US', 'CA')",
17+
name: :idx_users_pipeline_composite
18+
)
19+
end
20+
end
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
defmodule Algora.Repo.Migrations.OptimizeContributionScoreCalculation do
2+
use Ecto.Migration
3+
4+
def change do
5+
create_if_not_exists index(
6+
:user_contributions,
7+
[:user_id, :contribution_count, :repository_id],
8+
name: :idx_user_contributions_score_calc
9+
)
10+
11+
create_if_not_exists index(:repositories, [:id, :tech_stack, :topics, :stargazers_count],
12+
name: :idx_repositories_score_calc
13+
)
14+
end
15+
end
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
defmodule Algora.Repo.Migrations.AddContributionScoresToUsers do
2+
use Ecto.Migration
3+
4+
def change do
5+
alter table(:users) do
6+
add :contribution_scores, :map, default: %{}
7+
end
8+
9+
create index(:users, [:contribution_scores],
10+
using: :gin,
11+
name: :idx_users_contribution_scores_gin
12+
)
13+
end
14+
end

0 commit comments

Comments
 (0)