# openloops.facets

The board’s facet families: how a task is categorised, computed from what it is.

Every value is derived, never typed by hand: from the task’s `command` (through the
same deterministic reading the run plans use, [`openloops.command_risk`](openloops.command_risk.html.md#module-openloops.command_risk)), its
`org`, its `minutes` and its open `blocked_by` edges. The page draws its filter
from [`FAMILIES`](#openloops.facets.FAMILIES) (labels, help, value labels, order) and from each task’s
`facets`, so a family added here appears on the board with no page change.

Families, in the order the page shows them:

* `presence`: runs without you, or needs you at the terminal (a login, 2FA, a paste,
  a browser): the split the owner launches by.
* `ready`: every prerequisite done, waiting on an open issue, or unknown (the edges
  could not be read: never rounded into either).
* `where`: the Mac, the twb server, the iqb server.
* `risk`: the floor’s level (run, show, discuss, refuse).
* `touches`: what it changes (deploy, publish, secret, money, server, GitHub, deletes,
  exposure, local files).
* `org`: whose repository the task is in.
* `time`: the estimate’s bucket.

A task without a command gets `presence: by-hand` and no command-derived values.
Pure: no I/O.

### Module Attributes

| [`FAMILIES`](#openloops.facets.FAMILIES)   | (key, label, help, ((value, label), ...)).   |
|-------------------------------------------------------------|----------------------------------------------|

### Functions

| [`task_facets`](#openloops.facets.task_facets)(task)   | Each family's values for one task record (lists: a task can run on two machines).                                                 |
|----------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| [`families_payload`](#openloops.facets.families_payload)()  | [`FAMILIES`](#openloops.facets.FAMILIES) as JSON for the page: `[{key, label, help, values: [{value, label}]}]`. |

### openloops.facets.FAMILIES *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [str](https://docs.python.org/3/builtins/stdtypes.html#str), [str](https://docs.python.org/3/builtins/stdtypes.html#str), [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [str](https://docs.python.org/3/builtins/stdtypes.html#str)], ...]], ...]* *= (('presence', 'You needed', 'Whether a step needs you at the terminal: a login, 2FA, a paste, a browser.', (('unattended', 'Without you'), ('attended', 'Needs you'), ('by-hand', 'No command'))), ('ready', 'Ready', 'Waiting means an issue it depends on is still open.', (('ready', 'Ready'), ('waiting', 'Waiting on another'), ('unknown', 'Not read'))), ('where', 'Runs on', 'The machine the command acts on.', (('mac', 'Mac'), ('twb', 'twb server'), ('iqb', 'iqb server'))), ('risk', 'Risk', 'Shows first and Asks you by name wait for your yes.', (('run', 'Runs'), ('show', 'Shows first'), ('discuss', 'Asks you by name'), ('refuse', "Won't run"))), ('touches', 'Changes', 'What the command changes.', (('deploy', 'A deploy'), ('publish', 'A publish'), ('secret', 'A secret'), ('money', 'Money'), ('server', 'A server'), ('github', 'GitHub'), ('deletes', 'Deletes'), ('exposure', 'Makes public'), ('local', 'Local only'))), ('org', 'Org', 'Whose repository the task is in.', ()), ('time', 'Time', 'The estimate.', (('short', 'Under 5 min'), ('medium', '5 to 15 min'), ('long', 'Over 15 min'))))*

(key, label, help, ((value, label), …)). Values not listed (an org) are shown as is.

### openloops.facets.families_payload()

[`FAMILIES`](#openloops.facets.FAMILIES) as JSON for the page: `[{key, label, help, values: [{value, label}]}]`.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]]

### openloops.facets.task_facets(task)

Each family’s values for one task record (lists: a task can run on two machines).

```pycon
>>> f = task_facets({'command': "ssh tw 'python3 x.py --apply'", 'org': 'acme',
...                  'minutes': 3, 'blocked_by': []})
>>> f['presence'], f['where'], f['ready'], f['time'], f['org']
(['unattended'], ['twb'], ['ready'], ['short'], ['acme'])
>>> task_facets({'command': 'npm login && npm publish', 'blocked_by': None})['presence']
['attended']
>>> task_facets({'command': None, 'blocked_by': ['o/r#2']})['ready']
['waiting']
```

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]]
