processes.sort(key=lambda p: len(p.explicit_steps))
elif sort_by == '-steps':
processes.sort(key=lambda p: len(p.explicit_steps), reverse=True)
+ if sort_by == 'owners':
+ processes.sort(key=lambda p: p.n_owners or 0)
+ elif sort_by == '-owners':
+ processes.sort(key=lambda p: p.n_owners or 0, reverse=True)
elif sort_by == 'effort':
processes.sort(key=lambda p: p.effort.newest)
elif sort_by == '-effort':
self.explicit_steps: list[ProcessStep] = []
self.suppressed_steps: list[ProcessStep] = []
self.calendarize = calendarize
+ self.n_owners: int | None = None # only set by from_table_row
@classmethod
def from_table_row(cls, db_conn: DatabaseConnection,
row: Row | list[Any]) -> Process:
"""Make from DB row, with dependencies."""
+ # pylint: disable=no-member
process = super().from_table_row(db_conn, row)
assert isinstance(process.id_, int)
for name in ('title', 'description', 'effort'):
for row_ in db_conn.row_where('process_steps', 'owner',
process.id_):
step = ProcessStep.from_table_row(db_conn, row_)
- process.explicit_steps += [step] # pylint: disable=no-member
+ process.explicit_steps += [step]
for row_ in db_conn.row_where('process_step_suppressions', 'process',
process.id_):
step = ProcessStep.by_id(db_conn, row_[1])
- process.suppressed_steps += [step] # pylint: disable=no-member
+ process.suppressed_steps += [step]
for name in ('conditions', 'blockers', 'enables', 'disables'):
table = f'process_{name}'
assert isinstance(process.id_, int)
'process', process.id_):
target = getattr(process, name)
target += [Condition.by_id(db_conn, c_id)]
+ process.n_owners = len(process.used_as_step_by(db_conn))
return process
def used_as_step_by(self, db_conn: DatabaseConnection) -> list[Process]:
<table>
<tr>
<th><a href="?sort_by={% if sort_by == "steps" %}-{% endif %}steps">steps</a></th>
+<th><a href="?sort_by={% if sort_by == "owners" %}-{% endif %}owners">owners</a></th>
<th><a href="?sort_by={% if sort_by == "effort" %}-{% endif %}effort">effort</a></th>
<th><a href="?sort_by={% if sort_by == "title" %}-{% endif %}title">title</a></th>
</tr>
{% for process in processes %}
<tr>
<td>{{ process.explicit_steps|count }}</td>
+<td>{{ process.n_owners }}</td>
<td>{{ process.effort.newest }}</td>
<td><a href="process?id={{process.id_}}">{{process.title.newest}}</a></td>
</tr>