Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions lib/algora/workspace/workspace.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1183,17 +1183,21 @@ defmodule Algora.Workspace do
# Update all users that were queried from Cloud API to mark them as synced
users_map = Enum.group_by(users, & &1.provider_login)

Enum.each(users_without_contributions, fn provider_login ->
case users_map[provider_login] do
[user] ->
user
|> Ecto.Changeset.change(%{repo_contributions_synced: true})
|> Repo.update()
user_ids_to_update =
Enum.reduce(users_without_contributions, [], fn provider_login, acc ->
case users_map[provider_login] do
[user] ->
[user.id | acc]

_ ->
Logger.warning("User not found for marking as synced: #{provider_login}")
acc
end
end)

_ ->
Logger.warning("User not found for marking as synced: #{provider_login}")
end
end)
if not Enum.empty?(user_ids_to_update) do
Repo.update_all(from(u in User, where: u.id in ^user_ids_to_update), set: [repo_contributions_synced: true])
end
end

:ok
Expand Down
Loading