Skip to content

Commit 277758f

Browse files
committed
refactor: update contributor processing logic
- Replaced GitHub token usage with direct user fetching from the database using contributor ID. - Updated error logging to reflect the change in user identification from login to ID.
1 parent 77224e1 commit 277758f

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

lib/algora/workspace/jobs/process_contributors.ex

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,24 @@ defmodule Algora.Workspace.Jobs.ProcessContributors do
44
queue: :sync_contribution,
55
max_attempts: 3
66

7-
alias Algora.Github
8-
alias Algora.Workspace
97
alias Algora.Workspace.Jobs.ImportContributor
108

119
require Logger
1210

1311
@impl Oban.Worker
1412
def perform(%Oban.Job{args: %{"contributors_data" => contributors_data, "repo_id" => repo_id}}) do
15-
token = Github.TokenPool.get_token()
16-
1713
jobs =
1814
contributors_data
1915
|> Enum.reduce([], fn contributor_data, acc ->
20-
provider_login = contributor_data["login"]
16+
id = contributor_data["id"]
2117
contributions = contributor_data["contributions"]
2218

23-
case Workspace.ensure_user(token, provider_login) do
19+
case Algora.Repo.fetch(Algora.Accounts.User, id) do
2420
{:ok, user} ->
2521
[%{provider_login: user.provider_login, contributions: contributions} | acc]
2622

2723
{:error, reason} ->
28-
Logger.error("Failed to fetch user #{provider_login}: #{reason}")
24+
Logger.error("Failed to fetch user #{id}: #{reason}")
2925
acc
3026
end
3127
end)

0 commit comments

Comments
 (0)