示例#1
0
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)
示例#2
0
def value_txt_report(year_number, month_number, group="all"):
    start_date = munge_date(year=year_number, month=month_number, day=1)
    start_date = make_start_date(date=start_date)

    start_date, end_date = month_range(start_date)

    rg = ReportGroup(group, Kard.objects.done())
    done = rg.queryset

    cards = done.filter(done_date__gte=start_date,
                        done_date__lte=end_date).order_by('-done_date')

    cards = [c for c in cards if c.is_card]

    context = {
        'title': "Completed Value Cards",
        'cards': cards,
        'start_date': start_date,
        'end_date': end_date,
        'updated_at': datetime.datetime.now(),
        'version': VERSION,
    }

    response = make_response(render_template('done-report.txt', **context))
    response.headers['Content-Type'] = "text/plain"
    return response
示例#3
0
def value_txt_report(year_number, month_number, group="all"):
    start_date = munge_date(year=year_number, month=month_number, day=1)
    start_date = make_start_date(date=start_date)

    start_date, end_date = month_range(start_date)

    rg = ReportGroup(group, Kard.objects.done())
    done = rg.queryset

    cards = done.filter(done_date__gte=start_date,
        done_date__lte=end_date).order_by('-done_date')

    cards = [c for c in cards if c.is_card]

    context = {
        'title': "Completed Value Cards",
        'cards': cards,
        'start_date': start_date,
        'end_date': end_date,
        'updated_at': datetime.datetime.now(),
        'version': VERSION,
    }

    response = make_response(render_template('done-report.txt', **context))
    response.headers['Content-Type'] = "text/plain"
    return response
示例#4
0
    def test_month_range(self):
        from kardboard.util import month_range

        today = datetime.datetime(year=2011, month=6, day=12)
        start, end = month_range(today)
        self.assertEqual(6, start.month)
        self.assertEqual(1, start.day)
        self.assertEqual(2011, start.year)

        self.assertEqual(6, end.month)
        self.assertEqual(30, end.day)
        self.assertEqual(2011, end.year)
示例#5
0
    def test_month_range(self):
        from kardboard.util import month_range

        today = datetime.datetime(year=2011, month=6, day=12)
        start, end = month_range(today)
        self.assertEqual(6, start.month)
        self.assertEqual(1, start.day)
        self.assertEqual(2011, start.year)

        self.assertEqual(6, end.month)
        self.assertEqual(30, end.day)
        self.assertEqual(2011, end.year)
示例#6
0
    def done_in_month(self, year=None, month=None, day=None, date=None):
        """
        Kards that have been completed in the specified month.
        """
        if not date:
            date = munge_date(year=year, month=month, day=day)
            date = make_end_date(date=date)

        start_date, faux_end_date = month_range(date)

        results = self.done().filter(done_date__lte=date, done_date__gte=start_date)
        return results
示例#7
0
    def done_in_month(self, year=None, month=None, day=None, date=None):
        """
        Kards that have been completed in the specified month.
        """
        if not date:
            date = munge_date(year=year, month=month, day=day)
            date = make_end_date(date=date)

        start_date, faux_end_date = month_range(date)

        results = self.done().filter(done_date__lte=date,
                                     done_date__gte=start_date)
        return results
示例#8
0
    def test_wip(self):
        from kardboard.util import month_range

        rv = self.app.get(self._get_target_url())
        self.assertEqual(200, rv.status_code)

        date = datetime.datetime(self.year, self.month, self.day)
        start, date = month_range(date)
        expected_cards = self.Kard.in_progress(date)

        for c in expected_cards:
            self.assertIn(c.key, rv.data)

        expected = """<p class="value">%s</p>""" % expected_cards.count()
        self.assertIn(expected, rv.data)
示例#9
0
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)