@@ -836,9 +836,9 @@ defmodule AlgoraWeb.Org.JobLive do
836
836
837
837
socket
838
838
|> assign ( :developers , developers )
839
- |> assign ( :applicants , sort_applicants_by_contributions ( socket . assigns . job , applicants , contributions_map ) )
840
- |> assign ( :imports , sort_applicants_by_contributions ( socket . assigns . job , imports , contributions_map ) )
841
- |> assign ( :matches , sort_applicants_by_contributions ( socket . assigns . job , matches , contributions_map ) )
839
+ |> assign ( :applicants , sort_by_contributions ( socket . assigns . job , applicants , contributions_map ) )
840
+ |> assign ( :imports , sort_by_contributions ( socket . assigns . job , imports , contributions_map ) )
841
+ |> assign ( :matches , sort_by_contributions ( socket . assigns . job , matches , contributions_map ) )
842
842
|> assign ( :contributions_map , contributions_map )
843
843
end
844
844
@@ -1228,27 +1228,10 @@ defmodule AlgoraWeb.Org.JobLive do
1228
1228
|> Enum . group_by ( & & 1 . user . id )
1229
1229
end
1230
1230
1231
- # Sort applicants by their total number of contributions
1232
- defp sort_applicants_by_contributions ( job , applicants , contributions_map ) do
1231
+ defp sort_by_contributions ( job , applicants , contributions_map ) do
1233
1232
Enum . sort_by (
1234
1233
applicants ,
1235
- fn application ->
1236
- contributions = Map . get ( contributions_map , application . user . id , [ ] )
1237
-
1238
- Enum . reduce ( contributions , 0 , fn contribution , acc ->
1239
- stars = contribution . repository . stargazers_count
1240
- contribution_count = contribution . contribution_count
1241
-
1242
- delta =
1243
- if Enum . any? ( job . tech_stack , fn tech -> tech in Enum . take ( contribution . repository . tech_stack , 1 ) end ) do
1244
- :math . log ( stars + 1 ) * contribution_count
1245
- else
1246
- :math . pow ( :math . log ( stars + 1 ) * contribution_count , 0.5 )
1247
- end
1248
-
1249
- acc + delta
1250
- end )
1251
- end ,
1234
+ & Algora.Cloud . get_contribution_score ( job . tech_stack , & 1 . user , contributions_map ) ,
1252
1235
:desc
1253
1236
)
1254
1237
end
0 commit comments