The org module can perform organizational lookups and groupings using user/manager data.
["org"] USE-MODULES
# NOTE: You must set up an OrgContext first
'director1' org.FULL-ORG # Returns all usernames reporting up to director1
'director1' org.DIRECTS # Returns all direct reports of director1
'director1' org.DIRECT-MANAGERS # Returns all managers who directly report to director1
'user1' org.MANAGER org.MANAGER # Returns user1's manager's manager
( context -- )
Pushes an OrgContext (See org_module.py
) onto the org module's context stack.
The most recent context is used to perform org computations.
( -- )
Pops an OrgContext from the org module's context stack and throws it away.
( manager -- usernames )
Returns all usernames that roll up to manager.
( manager -- usernames )
Returns all manager usernames that roll up to manager.
( manager -- usernames )
Returns all managers who report directly to a manager.
( manager -- usernames )
Returns usernames
for everyone who report directly to a manager.
( items field leads default_lead -- record )
Groups a list of items by the specified leads.
The field
is the username for each item that will be used to roll an item up
into one of the specified leads
.
If an item can be rolled up into multiple leads, the lead that appears later in
the leads
list will be used.
If an item doesn't roll up into any of the specified leads, it is grouped into
the default_lead
.
( item field leads default_lead -- lead)
Returns the lead
that an item
rolls up into. See GROUP-BY-LEADS
for details on the arguments.
( username -- manager)
Returns the manager for the specified user.
( username root_username -- usernames)
Returns the management chain from the specified user to the specified root user. If the root user is not in the chain, then only the chain up to effective root is returned.
( root_username -- key_func )
Returns a key function that takes a username and returns the number of management levels to the root username. This can be used as the KEY-FUNC
to the SORT
word.
Example:
: USERS-TO-SORT ["user1" "mgr2" "mgr3" "director4"];
: ROOT-USER "ceouser";
USERS-TO-SORT ROOT-USER org.CHAIN-KEY-FUNC SORT-w/KEY-FUNC # Sorts by most senior person first
( -- users_managers )
Returns an array of [user manager]
pairs from the current org context.