Beispiel #1
0
def dashboard():
    today = timeutils.today()

    reporting_unit = request_arg('reporting_unit',
                                 default=config.REPORTING_WINDOW)
    previous_periods = int(request_arg('previous_periods', default=12))

    reporting_periods = [
        reporting_period(reporting_unit, today, -i)
        for i in reversed(xrange(previous_periods))
    ]
    current_period = reporting_periods[-1]

    developers = User.objects.developers()
    # Randomise order of developers with equal bug counts
    # FIXME: show developers as tied in template
    shuffle(developers)
    num_closed = lambda u: len(u.closed_issues().closed_in(
        current_period.start, current_period.end))
    # Rank from lowest number of closed bugs to highest
    ranked = sorted(((dev, num_closed(dev)) for dev in developers),
                    key=lambda pair: pair[1])

    # FIXME: this needs some work.
    # This currently makes 3 * previous_periods (i.e. 36) separate Mongo queries

    # Number of bugs opened/closed in each period
    opened_closed_bugs = [{
        'period':
        period,
        'opened':
        len(Issue.objects.opened_in(period.start, period.end)),
        'closed':
        len(Issue.objects.closed_in(period.start, period.end))
    } for period in reporting_periods]

    # Point-in-time open bug count
    open_bugs = [{
        'period': period,
        'count': len(Issue.objects.open_at(period.end))
    } for period in reporting_periods]

    # Close rate
    current_close_rate = opened_closed_bugs[-1]['closed'] - opened_closed_bugs[
        -1]['opened']
    previous_close_rate = opened_closed_bugs[-2][
        'closed'] - opened_closed_bugs[-2]['opened']
    close_rate_delta = abs(int(float(current_close_rate) / float(previous_close_rate) * 100)) \
        if previous_close_rate else float('inf')

    return render_template(
        'dashboard.jinja2',
        # Context vars
        today=today,
        period_label=reporting_unit,
        ranked=ranked,
        opened_closed_bugs=opened_closed_bugs,
        open_bugs=open_bugs,
        open_bug_count=open_bugs[-1]['count'],
        prev_open_bug_count=open_bugs[-2]['count'])
Beispiel #2
0
def old_bugs():
    "Display issues opened before some date."
    request_date = request_arg('opened-before')
    threshold = timeutils.with_local_tz(datetime.strptime(request_date, '%Y-%m-%d')) if request_date \
        else reporting.sprint_reporting_period(timeutils.today()).start

    issues = Issue.objects.older_than(threshold).order_by('-opened')

    return render_template('old-issues.jinja2', date=threshold, issues=issues)
Beispiel #3
0
def old_bugs():
    "Display issues opened before some date."
    request_date = request_arg('opened-before')
    threshold = timeutils.with_local_tz(datetime.strptime(request_date, '%Y-%m-%d')) if request_date \
        else reporting.sprint_reporting_period(timeutils.today()).start

    issues = Issue.objects.older_than(threshold).order_by('-opened')

    return render_template('old-issues.jinja2', date=threshold, issues=issues)
Beispiel #4
0
def dashboard():
    today = timeutils.today()

    reporting_unit = request_arg('reporting_unit', default=config.REPORTING_WINDOW)
    previous_periods = int(request_arg('previous_periods', default=12))

    reporting_periods = [reporting_period(reporting_unit, today, -i)
                         for i in reversed(xrange(previous_periods))]
    current_period = reporting_periods[-1]

    developers = User.objects.developers()
    # Randomise order of developers with equal bug counts
    # FIXME: show developers as tied in template
    shuffle(developers)
    num_closed = lambda u: len(u.closed_issues().closed_in(current_period.start,
                                                           current_period.end))
    # Rank from lowest number of closed bugs to highest
    ranked = sorted(((dev, num_closed(dev)) for dev in developers),
                    key=lambda pair: pair[1])

    # FIXME: this needs some work.
    # This currently makes 3 * previous_periods (i.e. 36) separate Mongo queries

    # Number of bugs opened/closed in each period
    opened_closed_bugs = [{'period': period,
                           'opened': len(Issue.objects.opened_in(period.start, period.end)),
                           'closed': len(Issue.objects.closed_in(period.start, period.end))}
                          for period in reporting_periods]

    # Point-in-time open bug count
    open_bugs = [{'period': period,
                  'count': len(Issue.objects.open_at(period.end))}
                 for period in reporting_periods]

    # Close rate
    current_close_rate = opened_closed_bugs[-1]['closed'] - opened_closed_bugs[-1]['opened']
    previous_close_rate = opened_closed_bugs[-2]['closed'] - opened_closed_bugs[-2]['opened']
    close_rate_delta = abs(int(float(current_close_rate) / float(previous_close_rate) * 100)) \
        if previous_close_rate else float('inf')

    return render_template('dashboard.jinja2',
                           # Context vars
                           today=today,
                           period_label=reporting_unit,
                           ranked=ranked,
                           opened_closed_bugs=opened_closed_bugs,
                           open_bugs=open_bugs,
                           open_bug_count=open_bugs[-1]['count'],
                           prev_open_bug_count=open_bugs[-2]['count'])