PhoenixKitStaff.Staff.Org (PhoenixKitStaff v0.6.0)

Copy Markdown View Source

Read-model / reporting over the staff org: the upcoming-birthdays widget and the full department → team → people org tree.

Extracted from PhoenixKitStaff.Staff, which keeps thin delegators (Staff.org_tree/0, Staff.upcoming_birthdays/1) so the public API is unchanged. org_tree/0 reads the people roster via Staff.list_people/0 (which already excludes trashed people).

Summary

Functions

Returns the full org tree: %{ departments: [%{department: ..., teams: [...], dept_only_people: [...]}], unassigned_people: [...] }

Returns upcoming birthdays within the given window (default 30 days), sorted by days-until-birthday.

Functions

org_tree()

@spec org_tree() :: %{
  departments: [
    %{
      department: PhoenixKitStaff.Schemas.Department.t(),
      teams: [
        %{
          team: PhoenixKitStaff.Schemas.Team.t(),
          people: [PhoenixKitStaff.Schemas.Person.t()]
        }
      ],
      dept_only_people: [PhoenixKitStaff.Schemas.Person.t()]
    }
  ],
  unassigned_people: [PhoenixKitStaff.Schemas.Person.t()]
}

Returns the full org tree: %{ departments: [%{department: ..., teams: [...], dept_only_people: [...]}], unassigned_people: [...] }

upcoming_birthdays(window_days \\ 30)

@spec upcoming_birthdays(non_neg_integer()) :: [
  %{
    person: PhoenixKitStaff.Schemas.Person.t(),
    next_birthday: Date.t(),
    days_until: non_neg_integer()
  }
]

Returns upcoming birthdays within the given window (default 30 days), sorted by days-until-birthday.