File tree Expand file tree Collapse file tree 1 file changed +19
-12
lines changed
lib/algora/workspace/jobs Expand file tree Collapse file tree 1 file changed +19
-12
lines changed Original file line number Diff line number Diff line change @@ -11,18 +11,25 @@ defmodule Algora.Workspace.Jobs.ImportStargazer do
11
11
@ impl Oban.Worker
12
12
def perform ( % Oban.Job { args: % { "provider_logins" => provider_logins , "repo_id" => repo_id } } ) do
13
13
with { :ok , users } <- Algora.Workspace . fetch_top_contributions_async ( Github.TokenPool . get_token ( ) , provider_logins ) do
14
- Repo . insert_all (
15
- Stargazer ,
16
- Enum . map ( users , fn user ->
17
- % {
18
- id: Nanoid . generate ( ) ,
19
- inserted_at: DateTime . utc_now ( ) ,
20
- updated_at: DateTime . utc_now ( ) ,
21
- user_id: user . id ,
22
- repository_id: repo_id
23
- }
24
- end )
25
- )
14
+ { count , _ } =
15
+ Repo . insert_all (
16
+ Stargazer ,
17
+ Enum . map ( users , fn user ->
18
+ % {
19
+ id: Nanoid . generate ( ) ,
20
+ inserted_at: DateTime . utc_now ( ) ,
21
+ updated_at: DateTime . utc_now ( ) ,
22
+ user_id: user . id ,
23
+ repository_id: repo_id
24
+ }
25
+ end )
26
+ )
27
+
28
+ if count > 0 do
29
+ :ok
30
+ else
31
+ { :error , :insert_all_failed }
32
+ end
26
33
end
27
34
end
28
35
You can’t perform that action at this time.
0 commit comments