2025 10 10 Leoben Supervisors
On the instance https://ematrix-vart.voestalpine.net we use HR-Import via GSS-Uploads and should asign the manager-id from the hr-file as a group and as a supervisor-id for the person being imported.
2025-10-10, Friday
The team Struzl Christoph has 13 members but they don’t have Struzl Christoph as their Supervisor.
Team - Struzl Christoph: 9d65c88-b324-4d8f-8dd5-7e371b1bcd3e
Manual Fix
data/super_visor_assigner.ex
defmodule SupervisorAsssigner do
require Logger
alias Emie.{
Repo,
People.Person,
People.Team,
}
import Ecto.Query
def teams_with_prefix(prefix \\ "Team - ") do
wildcard = "#{prefix}%"
from( t in Team, where: ilike(t.name, ^wildcard), order_by: [asc: t.name])
|> Repo.all()
end
def teams_with_supervisor_and_members(teams) do
Enum.map( teams, fn team ->
teamlead_id =
case team.teamlead_ids do
[tlid] -> tlid
[tlid|_] -> Logger.warn("Team #{team.name} has more than one TL. Using first #{tlid}")
tlid
err -> Logger.error("Team #{team.name} has no TL. Ignoring team. #{inspect err}")
nil
end
%{ team: team, teamlead_id: teamlead_id }
end)
|> Enum.reject( fn r -> is_nil( r.teamlead_id) end)
|> Enum.map( fn %{team: team, teamlead_id: teamlead_id} ->
team_with_members = team |> Repo.preload(:members)
%{ team: team, teamlead_id: teamlead_id, members: team_with_members.members }
end)
end
def set_supervisor_ids(rec) do
Enum.map( rec, fn %{team: team, teamlead_id: teamlead_id, members: members } ->
updates =
Enum.map( members, fn person ->
p = Repo.get_by(Person, id: person.id)
Ecto.Changeset.change(p, %{supervisor_id: teamlead_id})
|> Map.put(:action, :update)
|> Repo.update()
end)
%{team: team, teamlead_id: teamlead_id, members: members, updated: updates}
end)
end
end
Permanent Fix
The call to Emie.Import.AdjustSupervisor.run/0
was missing in the GSS-API.