Start an epic's issues in order of score, scoring each that holds none

This commit is contained in:
Lilleman
2026-11-20 14:30:30 +01:00
parent abaf54bc46
commit 5f2a4b6385
19 changed files with 615 additions and 83 deletions
+14 -1
View File
@@ -5,8 +5,9 @@ import dataclasses
import re
import typing
from plan.todo_table import Exempt, Moves
from plan.todo_table import Exempt, item_fields, ItemFields, Moves, MOVES
from failure import Failure
from plan_store.jira_epic import SET_SCORES
# What a tracker accepts as a label: Jira refuses a label holding white space.
LABEL = re.compile(r"\S+")
@@ -63,6 +64,9 @@ class EpicStore(typing.Protocol):
def comment(self, key: str, text: str) -> None | Failure:
"""Posts text, markdown, as a comment on the epic's child issue named key, for the people who work the epic to read. A sub-task, an issue outside the epic, or an empty or blank text is refused."""
def set_scores(self, key: str, scores: dict[str, int], moves: str, comment: str) -> None | Failure:
"""Sets the scores of the epic's child issue named key, or of a sub-task of one, then posts comment, markdown, on it, since a tracker's screens may not show the scores. scores holds each of L, E, I and S, and moves is the plan's Moves cell, which may be empty. An issue that holds a score keeps what it holds and is refused, as are an issue outside the epic and a blank comment. Where the comment fails after the scores are set, the Failure says so."""
def finish_issue(self, key: str) -> None | Failure:
"""Moves the epic's child issue named key, or a sub-task of one, to a done status, so that read answers it as done; one already done stays as it is. An issue outside the epic is refused. A Failure says why the move could not be made: the issue's workflow gives no way to a done status, gives several the backend cannot choose between, or refuses the move."""
@@ -103,6 +107,15 @@ def no_child(epic_key: str, key: str, done_to_it: str) -> Failure:
return Failure(f"{key} is not one of the child issues of the epic {epic_key}, so it cannot be {done_to_it}")
def no_scores(key: str, scores: dict[str, int], moves: str, held: dict[str, int]) -> ItemFields | Failure:
"""The scores and Moves to set on the issue named key, each held to the plan's format, or why no tracker sets them; held are the scores the issue has."""
if held:
return Failure(f"{key} holds scores already, which stay as they are")
if sorted(scores) != sorted(SET_SCORES):
return Failure(f"{key} is scored on {', '.join(scores) or 'nothing'}: set each of {', '.join(SET_SCORES[:-1])} and {SET_SCORES[-1]}, and nothing else")
return item_fields({name: str(value) for name, value in scores.items()} | {MOVES: moves}, f"item {key}")
def no_words(text: str) -> Failure | None:
"""Why no tracker can post this comment; None where one can."""
return None if text.strip() else Failure("the comment must hold some text")