From: Christian Heller Date: Thu, 6 Jun 2024 04:23:57 +0000 (+0200) Subject: To Processes listing, add sortable column for number of owners. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/static/%7B%7B%20web_path%20%7D%7D/decks/tasks?a=commitdiff_plain;h=80e2cf170d408e7d183301ea3fba0df65ec261d5;p=plomtask To Processes listing, add sortable column for number of owners. --- diff --git a/plomtask/http.py b/plomtask/http.py index 2b630a2..886efa2 100644 --- a/plomtask/http.py +++ b/plomtask/http.py @@ -280,6 +280,10 @@ class TaskHandler(BaseHTTPRequestHandler): 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': diff --git a/plomtask/processes.py b/plomtask/processes.py index 23da7c1..8082c3c 100644 --- a/plomtask/processes.py +++ b/plomtask/processes.py @@ -44,11 +44,13 @@ class Process(BaseModel[int], ConditionsRelations): 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'): @@ -58,11 +60,11 @@ class Process(BaseModel[int], ConditionsRelations): 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) @@ -70,6 +72,7 @@ class Process(BaseModel[int], ConditionsRelations): '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]: diff --git a/templates/processes.html b/templates/processes.html index 42beafc..c057890 100644 --- a/templates/processes.html +++ b/templates/processes.html @@ -11,12 +11,14 @@ + {% for process in processes %} +
stepsowners effort title
{{ process.explicit_steps|count }}{{ process.n_owners }} {{ process.effort.newest }} {{process.title.newest}}