@@ -643,23 +643,35 @@ defmodule Algora.Workspace do
643643 def list_user_contributions ( ids , opts \\ [ ] ) do
644644 query =
645645 from uc in UserContribution ,
646+ where: uc . user_id in ^ ids ,
646647 join: u in assoc ( uc , :user ) ,
647648 join: r in assoc ( uc , :repository ) ,
648649 join: repo_owner in assoc ( r , :user ) ,
649- where: u . id in ^ ids ,
650- where: not ilike ( r . name , "%awesome%" ) ,
651- where: not ilike ( r . name , "%algorithms%" ) ,
652- where: not ilike ( r . name , "%exercises%" ) ,
653- where: not ilike ( r . name , "%tutorials%" ) ,
654- where: not ilike ( repo_owner . provider_login , "%algorithms%" ) ,
655- where: not ilike ( repo_owner . provider_login , "%firstcontributions%" ) ,
656650 where: repo_owner . type == :organization or r . stargazers_count > 200 ,
657651 # where: fragment("? && ?::citext[]", r.tech_stack, ^(opts[:tech_stack] || [])),
652+ where:
653+ not ( ilike ( r . name , "%awesome%" ) or
654+ ilike ( r . name , "%algorithms%" ) or
655+ ilike ( r . name , "%exercises%" ) or
656+ ilike ( r . name , "%tutorials%" ) ) ,
657+ where:
658+ not ( ilike ( repo_owner . provider_login , "%algorithms%" ) or
659+ ilike ( repo_owner . provider_login , "%firstcontributions%" ) ) ,
658660 order_by: [
659661 desc: fragment ( "CASE WHEN ? && ?::citext[] THEN 1 ELSE 0 END" , r . tech_stack , ^ ( opts [ :tech_stack ] || [ ] ) ) ,
660662 desc: r . stargazers_count
661663 ] ,
662- select_merge: % { user: u , repository: % { r | user: repo_owner } }
664+ select: % UserContribution {
665+ contribution_count: uc . contribution_count ,
666+ user: map ( u , [ :id , :provider_login ] ) ,
667+ repository: % {
668+ id: r . id ,
669+ name: r . name ,
670+ stargazers_count: r . stargazers_count ,
671+ tech_stack: r . tech_stack ,
672+ user: map ( repo_owner , [ :id , :provider_login , :type , :name , :avatar_url , :stargazers_count ] )
673+ }
674+ }
663675
664676 query =
665677 case opts [ :limit ] do
@@ -748,11 +760,17 @@ defmodule Algora.Workspace do
748760 |> Oban . insert ( )
749761
750762 _ ->
763+ Logger . error ( "User not found for #{ contribution . provider_login } " )
751764 { :error , :user_not_found }
752765 end
753766 end )
754767
755- if Enum . any? ( results , & match? ( { :ok , _ } , & 1 ) ) , do: :ok , else: { :error , :failed }
768+ if Enum . any? ( results , & match? ( { :ok , _ } , & 1 ) ) do
769+ :ok
770+ else
771+ Logger . error ( "Failed to add contributions: #{ inspect ( results ) } " )
772+ { :error , :failed }
773+ end
756774 end
757775
758776 defp add_contributions ( token , users , contributions ) do
0 commit comments