Skip to content

Commit 194dc2f

Browse files
committed
update job config
1 parent 70b6420 commit 194dc2f

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

config/config.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ config :algora, Oban,
5858
activity_mailer: 1,
5959
activity_discord: 10,
6060
campaign_emails: 1,
61-
fetch_top_contributions: 3,
61+
fetch_top_contributions: 1,
6262
sync_contribution: 3
6363
]
6464

lib/algora/admin/admin.ex

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ defmodule Algora.Admin do
2727
User
2828
|> where([u], not is_nil(u.handle))
2929
|> where([u], not is_nil(u.provider_login))
30+
|> where([u], u.type == :individual)
3031
|> where([u], fragment("not exists (select 1 from user_contributions where user_contributions.user_id = ?)", u.id))
3132

3233
query =
@@ -38,21 +39,25 @@ defmodule Algora.Admin do
3839

3940
Repo.transaction(
4041
fn ->
41-
query
42-
|> Repo.stream()
43-
|> Enum.each(fn user ->
44-
if opts[:dry_run] do
45-
IO.puts("Enqueued job for #{user.provider_login}")
46-
else
42+
if opts[:dry_run] do
43+
query
44+
|> Repo.stream()
45+
|> Enum.to_list()
46+
|> length()
47+
|> IO.puts()
48+
else
49+
query
50+
|> Repo.stream()
51+
|> Enum.each(fn user ->
4752
%{provider_login: user.provider_login}
4853
|> Workspace.Jobs.FetchTopContributions.new()
4954
|> Oban.insert()
5055
|> case do
5156
{:ok, _job} -> IO.puts("Enqueued job for #{user.provider_login}")
5257
{:error, error} -> IO.puts("Failed to enqueue job for #{user.provider_login}: #{inspect(error)}")
5358
end
54-
end
55-
end)
59+
end)
60+
end
5661
end,
5762
timeout: :infinity
5863
)

lib/algora/workspace/jobs/fetch_top_contributions.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ defmodule Algora.Workspace.Jobs.FetchTopContributions do
1111
Algora.Workspace.fetch_top_contributions_async(provider_login)
1212
end
1313

14-
def timeout(_), do: :timer.seconds(10)
14+
def timeout(_), do: :timer.seconds(30)
1515
end

0 commit comments

Comments
 (0)