Skip to content

Commit 1ee03cb

Browse files
committed
feat: add discovery tech stack and language contributions schema
- Introduced a new field `discovery_tech_stack` to the User schema, allowing for an array of strings. - Created a migration to add the `discovery_tech_stack` field to the users table and populate it based on the existing `tech_stack`. - Added a new migration for the `language_contributions` table, including fields for user ID, language, pull requests count, and contribution percentage.
1 parent f4d3cf8 commit 1ee03cb

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

lib/algora/accounts/schemas/user.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ defmodule Algora.Accounts.User do
3939
field :stargazers_count, :integer, default: 0
4040
field :domain, :string
4141
field :tech_stack, {:array, :string}, default: []
42+
field :discovery_tech_stack, {:array, :string}, default: []
4243
field :categories, {:array, :string}, default: []
4344
field :featured, :boolean, default: false
4445
field :priority, :integer, default: 0
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
defmodule Algora.Repo.Migrations.CreateLanguageContributions do
2+
use Ecto.Migration
3+
4+
def change do
5+
create table(:language_contributions) do
6+
add :user_id, :string, null: false
7+
add :language, :citext, null: false
8+
add :prs, :integer, null: false
9+
add :percentage, :decimal, null: false
10+
11+
timestamps()
12+
end
13+
14+
create unique_index(:language_contributions, [:user_id, :language])
15+
create index(:language_contributions, [:user_id])
16+
create index(:language_contributions, [:language])
17+
end
18+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
defmodule Algora.Repo.Migrations.AddDiscoveryTechStackToUsers do
2+
use Ecto.Migration
3+
4+
def up do
5+
alter table(:users) do
6+
add :discovery_tech_stack, {:array, :citext}, default: []
7+
end
8+
9+
execute("UPDATE users SET discovery_tech_stack = tech_stack WHERE tech_stack != '{}'")
10+
end
11+
12+
def down do
13+
alter table(:users) do
14+
remove :discovery_tech_stack
15+
end
16+
end
17+
end

0 commit comments

Comments
 (0)