@@ -654,12 +654,10 @@ defmodule Algora.Workspace do
654654 end
655655 end
656656
657- def fetch_top_contributions ( provider_login ) do
658- token = Algora.Admin . token ( )
659-
657+ def fetch_top_contributions ( token , provider_login ) do
660658 with { :ok , contributions } <- Algora.Cloud . top_contributions ( provider_login ) ,
661659 { :ok , user } <- ensure_user ( token , provider_login ) ,
662- :ok <- add_contributions ( user . id , contributions ) do
660+ :ok <- add_contributions ( token , user . id , contributions ) do
663661 { :ok , contributions }
664662 else
665663 { :error , reason } ->
@@ -668,12 +666,10 @@ defmodule Algora.Workspace do
668666 end
669667 end
670668
671- def fetch_top_contributions_async ( provider_login ) do
672- token = Algora.Admin . token ( )
673-
669+ def fetch_top_contributions_async ( token , provider_login ) do
674670 with { :ok , contributions } <- Algora.Cloud . top_contributions ( provider_login ) ,
675671 { :ok , user } <- ensure_user ( token , provider_login ) ,
676- { :ok , _ } <- add_contributions_async ( user . id , contributions ) do
672+ { :ok , _ } <- add_contributions_async ( token , user . id , contributions ) do
677673 { :ok , nil }
678674 else
679675 { :error , reason } ->
@@ -682,7 +678,7 @@ defmodule Algora.Workspace do
682678 end
683679 end
684680
685- def add_contributions_async ( user_id , opts ) do
681+ def add_contributions_async ( _token , user_id , opts ) do
686682 Repo . transact ( fn ->
687683 Enum . reduce_while ( opts , :ok , fn contribution , _ ->
688684 case % {
@@ -699,18 +695,26 @@ defmodule Algora.Workspace do
699695 end )
700696 end
701697
702- def add_contributions ( user_id , opts ) do
698+ def add_contributions ( token , user_id , opts ) do
703699 results =
704700 Enum . map ( opts , fn % { repo_name: repo_name , contribution_count: contribution_count } ->
705- add_contribution ( % { user_id: user_id , repo_full_name: repo_name , contribution_count: contribution_count } )
701+ add_contribution ( % {
702+ token: token ,
703+ user_id: user_id ,
704+ repo_full_name: repo_name ,
705+ contribution_count: contribution_count
706+ } )
706707 end )
707708
708709 if Enum . any? ( results , fn result -> result == :ok end ) , do: :ok , else: { :error , :failed }
709710 end
710711
711- def add_contribution ( % { user_id: user_id , repo_full_name: repo_full_name , contribution_count: contribution_count } ) do
712- token = Algora.Admin . token ( )
713-
712+ def add_contribution ( % {
713+ token: token ,
714+ user_id: user_id ,
715+ repo_full_name: repo_full_name ,
716+ contribution_count: contribution_count
717+ } ) do
714718 with [ repo_owner , repo_name ] <- String . split ( repo_full_name , "/" ) ,
715719 { :ok , repo } <- ensure_repository ( token , repo_owner , repo_name ) ,
716720 { :ok , _tech_stack } <- ensure_repo_tech_stack ( token , repo ) ,
0 commit comments