{% extends "layout.html" %}
{% block sidebar %}{% include "lintian-fixes/sidebar.html" %}{% endblock %}
{% from "lintian-fixes/util.html" import lintian_tag_link %}
{% block page_title %}Absorbed Lintian Fixes - Statistics{% endblock %}
{% block body %}
<div class="section" id="absorbed-lintian-fixes-stats">
<h1>Lintian Fixes - Statistics</h1>

<div class="absorbed">
<h2>Number of Fixes by Tag</h2>
<p>Absorbed fixes are fixes that have either been pushed directly by the Janitor, or
have been <a href="/lintian-fixes/merge-proposals">proposed as a merge request
and then merged</a>.</p>
<table id="tags-table" class="docutils display" border="1">
<thead valign="bottom">
<tr class="row-odd">
  <th class="head">Lintian Tag</th>
  <th class="head">Previously merged/pushed</th>
  <th class="head">Ready but not yet merged/pushed</th>
</tr>
</thead>
<tbody valign="top" name="tag-table">
{% for tag, absorbed_count, unabsorbed_count, total_count in by_tag %}
<tr>
    <td>{{ lintian_tag_link(tag) }}</td>
    <td>{{ absorbed_count }}</td>
    <td>{{ unabsorbed_count }}</td>
</tr>
{% endfor %}
<tr>
    <td><b>Total</b></td>
    <td><b>{{ by_tag | sum(attribute=1) }}</b></td>
    <td><b>{{ by_tag | sum(attribute=2) }}</b></td>
</tr>
</table>

<script>$(document).ready(function() {$('#tags-table').DataTable({"pageLength": 500, "lengthMenu": [50, 200, 500, 1000, -1], "order": []}); });</script>


<h2>Burndown</h2>

<canvas id="burndown" width="800" height="450"></canvas>
<script>
$.getJSON("/cupboard/stats/+chart/burndown?suite=lintian-fixes", function (json) {
new Chart($("#burndown"), {
    type: 'line',
    data: {
      datasets: [{
        label: 'Packages remaining',
        backgroundColor: window.chartColors.red,
        borderColor: window.chartColors.red,
	data: $.map(json, function(entry) { return { t: moment(entry[0]).toDate(), y: entry[1] } } ),
      }],
    },
    options: {
      title: { display: true, text: 'Package burndown' },
      scales: {
        xAxes: [{
	  type: 'time',
          distribution: 'series',
	  offset: true,
	  ticks: {
	    major: {
	      enabled: true,
	      fontStyle: 'bold'
            },
            source: 'data',
            autoSkip: true,
            autoSkipPadding: 75,
            maxRotation: 0,
            sampleSize: 100
	  },
	}],
        yAxes: [{
          display: true,
          ticks: {
              beginAtZero: true   // minimum value will be 0.
          }
        }],
      }
    },
});
});
</script>

<canvas id="tags-per-run-chart" width="800" height="450"></canvas>
<script>
new Chart($("#tags-per-run-chart"), {
    type: 'bar',
    data: {
       labels: {{ tags_per_run.items()|list|sort|map(attribute=0)|list|tojson }},
       datasets: [{
         label: "Number of fixers applied",
         backgroundColor: Chart.helpers.color(window.chartColors.blue).alpha(0.5).rgbString(),
         data: {{ tags_per_run.items()|list|sort|map(attribute=1)|list|tojson }}
       }],
    },
    options: {
      title: { text: "Tags fixed per run", display: true },
    },
});
</script>

<canvas id="lintian-brush-versions-chart" width="800" height="450"></canvas>
<script>
new Chart($("#lintian-brush-versions-chart"), {
    type: 'bar',
    data: {
       labels: {{ lintian_brush_versions.items()|list|sort|map(attribute=0)|list|tojson }},
       datasets: [{
         label: "Runs per lintian-brush version",
         backgroundColor: Chart.helpers.color(window.chartColors.blue).alpha(0.5).rgbString(),
         data: {{ lintian_brush_versions.items()|list|sort|map(attribute=1)|list|tojson }}
       }],
    }
});
</script>

</div>
</div>
{% endblock %}
