Skip to content

Commit 2ad560d

Browse files
committed
autoupdate domain if nil
1 parent 4466717 commit 2ad560d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/algora_web/live/admin/seed_live.ex

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,12 @@ defmodule AlgoraWeb.Admin.SeedLive do
294294
defp get_user(%{"org_handle" => handle} = _row) when is_binary(handle) and handle != "" do
295295
run_cached(handle, fn ->
296296
with {:ok, user} <- Workspace.ensure_user(Algora.Admin.token(), handle) do
297+
if is_nil(user.domain) or String.trim(user.domain) == "" do
298+
user
299+
|> change(%{domain: Algora.Util.to_domain(user.website_url)})
300+
|> Repo.update()
301+
end
302+
297303
Repo.fetch(User, user.id)
298304
end
299305
end)
@@ -304,6 +310,12 @@ defmodule AlgoraWeb.Admin.SeedLive do
304310

305311
run_cached(domain, fn ->
306312
with {:ok, user} <- fetch_or_create_user(domain, %{hiring: true, tech_stack: row["tech_stack"]}) do
313+
if is_nil(user.domain) or String.trim(user.domain) == "" do
314+
user
315+
|> change(%{domain: domain})
316+
|> Repo.update()
317+
end
318+
307319
Repo.fetch(User, user.id)
308320
end
309321
end)

0 commit comments

Comments
 (0)