Add better support for backlog and rejected stories

This commit is contained in:
Sijmen 2018-08-17 15:51:40 +02:00
parent 0068ec8d50
commit 89c1dd4f73
3 changed files with 33 additions and 22 deletions

View File

@ -6,15 +6,23 @@ COLOR_TITLE = Color(Color.YELLOW)
COLOR_HEADER = Color(Color.CYAN)
COLOR_WHITE = Color(Color.BRIGHT_WHITE)
COLOR_PLANNED = Color(Color.BRIGHT_BLACK)
COLOR_STARTED = Color(226)
COLOR_FINISHED = Color(Color.BRIGHT_BLUE)
COLOR_DELIVERED = Color(208)
COLOR_ACCEPTED = Color(Color.BRIGHT_GREEN)
COLOR_REJECTED = Color(Color.BRIGHT_RED)
def _format_state(state: str) -> str:
STATES = {
'accepted': '\033[92maccepted\033[0m',
'delivered': '\033[38;5;208mdelivered\033[0m',
'finished': '\033[94mfinished\033[0m',
'started': '\033[38;5;226mstarted\033[0m',
'planned': '\033[90mplanned\033[0m',
'unstarted': '\033[90munstarted\033[0m',
'accepted': COLOR_ACCEPTED.format('accepted'),
'rejected': COLOR_REJECTED.format('rejected'),
'delivered': COLOR_DELIVERED.format('delivered'),
'finished': COLOR_FINISHED.format('finished'),
'started': COLOR_STARTED.format('started'),
'planned': COLOR_PLANNED.format('planned'),
'unstarted': COLOR_PLANNED.format('unstarted'),
}
return STATES[state]

View File

@ -10,24 +10,21 @@ import tabulate
import api.projects
import api.stories
from config import Config
from util import require_login, Color
from util import require_login
from . import COLOR_HEADER, _format_state, _get_persons
from . import COLOR_HEADER, COLOR_PLANNED, COLOR_STARTED, COLOR_FINISHED, \
COLOR_DELIVERED, COLOR_ACCEPTED, COLOR_REJECTED, _format_state, \
_get_persons
from ._stories_info import stories_info
from .cli import cli
STATES = 'unstarted', 'planned', 'started', 'finished', 'delivered', 'accepted'
STATES = 'unstarted', 'planned', 'started', 'finished', 'delivered', \
'accepted', 'rejected'
Persons = Dict[int, Dict[str, Any]]
Totals = DefaultDict[int, Dict[str, int]]
COLOR_PLANNED = Color(Color.BRIGHT_BLACK)
COLOR_STARTED = Color(226)
COLOR_FINISHED = Color(Color.BRIGHT_BLUE)
COLOR_DELIVERED = Color(208)
COLOR_ACCEPTED = Color(Color.BRIGHT_GREEN)
def __ceil(value: float) -> int:
return int(math.ceil(value))
@ -40,13 +37,16 @@ def __get_row(item: Tuple[int, Dict[str, int]], persons: Persons,
estimates = [points[state] for state in STATES]
progress = '['
progress += COLOR_PLANNED.format('P' * __ceil(points['planned']))
progress += COLOR_STARTED.format('S' * __ceil(points['started']))
progress += COLOR_FINISHED.format('F' * __ceil(points['finished']))
progress += COLOR_DELIVERED.format('D' * __ceil(points['delivered']))
progress = '[' + \
COLOR_PLANNED.format('P' * __ceil(points['planned'])) + \
COLOR_REJECTED.format('R' * __ceil(points['rejected'])) + \
COLOR_STARTED.format('S' * __ceil(points['started'])) + \
COLOR_FINISHED.format('F' * __ceil(points['finished'])) + \
COLOR_DELIVERED.format('D' * __ceil(points['delivered']))
if show_accepted:
progress += COLOR_ACCEPTED.format('A' * __ceil(points['accepted']))
progress += ']'
return name, (*estimates), sum(estimates), progress
@ -154,7 +154,7 @@ def _stories_current(project: str, scope: str, show_accepted: bool) -> None:
iterations = api.projects.get_iterations(
token, project_id, scope=scope)
if not iterations:
print('No current iteration.')
print('No stories in', scope)
return
iteration = iterations[0]
@ -164,7 +164,8 @@ def _stories_current(project: str, scope: str, show_accepted: bool) -> None:
__print_stories(iteration['stories'], persons, totals, show_accepted)
__print_totals(totals, persons, show_accepted)
__print_burndown(token, iteration, show_accepted)
if scope == 'current':
__print_burndown(token, iteration, show_accepted)
def _set_story_state(story: str, state: str) -> None:

View File

@ -44,6 +44,8 @@ class Color:
color_str = ';'.join(colors)
text = ' '.join(str(a) for a in args)
if not text:
return ''
return f'\033[{color_str}m{text}\033[0m'