def main(): states = States() backlogged_states = [] for k in Kard.backlogged(): if k.state not in states: if k.state not in backlogged_states: backlogged_states.append(k.state) k.state = states.backlog k.save() start_states = [] for k in Kard.in_progress(): if k.state not in states: if k.state not in start_states: start_states.append(k.state) k.state = states.start k.save() print "Valid states" print states print "Backlogged states that went away" print backlogged_states print "Start states that went away" print start_states
def state(): date = datetime.datetime.now() date = make_end_date(date=date) board = DisplayBoard() # defaults to all teams, 7 days of done title = app.config.get('SITE_NAME') wip_cards = Kard.in_progress(date) backlog_cards = Kard.backlogged(date) metrics = [ {'Ave. Cycle Time': Kard.objects.moving_cycle_time( year=date.year, month=date.month, day=date.day)}, {'Done this week': Kard.objects.done_in_week( year=date.year, month=date.month, day=date.day).count()}, {'Done this month': Kard.objects.done_in_month( year=date.year, month=date.month, day=date.day).count()}, {'On the board': wip_cards.count() + backlog_cards.count()}, ] context = { 'title': title, 'board': board, 'states': states, 'metrics': metrics, 'date': date, 'updated_at': datetime.datetime.now(), 'version': VERSION, } return render_template('state.html', **context)
def dashboard(year=None, month=None, day=None): date = kardboard.util.now() now = kardboard.util.now() scope = "current" if year: date = date.replace(year=year) scope = "year" if month: date = date.replace(month=month) scope = "month" start, end = month_range(date) date = end if day: date = date.replace(day=day) scope = "day" date = make_end_date(date=date) wip_cards = list(Kard.in_progress(date)) wip_cards = sorted(wip_cards, key=lambda c: c.current_cycle_time(date)) wip_cards.reverse() backlog_cards = Kard.backlogged(date).order_by("key") metrics = [ {"Ave. Cycle Time": Kard.objects.moving_cycle_time(year=date.year, month=date.month, day=date.day)}, {"Done this week": Kard.objects.done_in_week(year=date.year, month=date.month, day=date.day).count()}, {"Done this month": Kard.objects.done_in_month(year=date.year, month=date.month, day=date.day).count()}, {"On the board": len(wip_cards) + backlog_cards.count()}, ] title = "Dashboard" if scope == "year": title += " for %s" if scope == "month": title += " for %s/%s" % (date.month, date.year) if scope == "day" or scope == "current": title += " for %s/%s/%s" % (date.month, date.day, date.year) forward_date = date + relativedelta.relativedelta(days=1) back_date = date - relativedelta.relativedelta(days=1) if forward_date > now: forward_date = None context = { "forward_date": forward_date, "back_date": back_date, "scope": scope, "date": date, "title": title, "metrics": metrics, "wip_cards": wip_cards, "backlog_cards": backlog_cards, "updated_at": now, "version": VERSION, } return render_template("dashboard.html", **context)
def state(): date = datetime.datetime.now() date = make_end_date(date=date) board = DisplayBoard() # defaults to all teams, 7 days of done title = app.config.get("SITE_NAME") wip_cards = Kard.in_progress(date) backlog_cards = Kard.backlogged(date) metrics = [ {"Ave. Cycle Time": Kard.objects.moving_cycle_time(year=date.year, month=date.month, day=date.day)}, {"Done this week": Kard.objects.done_in_week(year=date.year, month=date.month, day=date.day).count()}, {"Done this month": Kard.objects.done_in_month(year=date.year, month=date.month, day=date.day).count()}, {"On the board": wip_cards.count() + backlog_cards.count()}, ] context = { "title": title, "board": board, "states": states, "metrics": metrics, "date": date, "updated_at": datetime.datetime.now(), "version": VERSION, } return render_template("team.html", **context)
def calculate(cls, group="all"): from kardboard.models import Kard from kardboard.models import ReportGroup try: record = cls.objects.get(group=group) except cls.DoesNotExist: record = cls() record.group = group record.data = {} kards = ReportGroup(group, Kard.in_progress()) record.data = report_on_cards(list(kards.queryset)) record.save() return record
def calculate(cls, group="all"): from kardboard.models import Kard from kardboard.models import ReportGroup try: record = cls.objects.get( group=group, ) except cls.DoesNotExist: record = cls() record.group = group record.data = {} kards = ReportGroup(group, Kard.in_progress()) record.data = report_on_cards(list(kards.queryset)) record.save() return record
def dashboard(year=None, month=None, day=None): date = kardboard.util.now() now = kardboard.util.now() scope = 'current' if year: date = date.replace(year=year) scope = 'year' if month: date = date.replace(month=month) scope = 'month' start, end = month_range(date) date = end if day: date = date.replace(day=day) scope = 'day' date = make_end_date(date=date) wip_cards = list(Kard.in_progress(date)) wip_cards = sorted(wip_cards, key=lambda c: c.current_cycle_time(date)) wip_cards.reverse() backlog_cards = Kard.backlogged(date).order_by('key') metrics = [ {'Ave. Cycle Time': Kard.objects.moving_cycle_time( year=date.year, month=date.month, day=date.day)}, {'Done this week': Kard.objects.done_in_week( year=date.year, month=date.month, day=date.day).count()}, {'Done this month': Kard.objects.done_in_month( year=date.year, month=date.month, day=date.day).count()}, {'On the board': len(wip_cards) + backlog_cards.count()}, ] title = "Dashboard" if scope == 'year': title += " for %s" if scope == 'month': title += " for %s/%s" % (date.month, date.year) if scope == 'day' or scope == 'current': title += " for %s/%s/%s" % (date.month, date.day, date.year) forward_date = date + relativedelta.relativedelta(days=1) back_date = date - relativedelta.relativedelta(days=1) if forward_date > now: forward_date = None context = { 'forward_date': forward_date, 'back_date': back_date, 'scope': scope, 'date': date, 'title': title, 'metrics': metrics, 'wip_cards': wip_cards, 'backlog_cards': backlog_cards, 'updated_at': now, 'version': VERSION, } return render_template('dashboard.html', **context)
from kardboard.models import Kard from kardboard.tasks import force_update_ticket for k in Kard.in_progress(): force_update_ticket.delay(k.id) print "Queued updates for %s WIP cards" % (Kard.in_progress().count()) for k in Kard.backlogged(): force_update_ticket.delay(k.id) print "Queued updates for %s backlogged cards" % (Kard.backlogged().count()) for k in Kard.objects.done(): force_update_ticket.delay(k.id) print "Queued updates for %s done cards" % (Kard.objects.done().count())