Added filtering of minor authors to the tables in the HTML output.

In practice, this means that the tables are initially collapsed and hide
all authors with a workload below one percent. The user can expand a
table in order to show all authors found during statistical analysis.
This commit is contained in:
Adam Waldenberg 2013-05-08 16:53:20 +02:00
parent b50f85ba17
commit 10179d12ed
3 changed files with 59 additions and 7 deletions

View file

@ -172,17 +172,20 @@ class BlameOutput(Outputable):
total_blames += i[1].rows
for i, entry in enumerate(blames):
work_percentage = str("{0:.2f}".format(100.0 * entry[1].rows / total_blames))
blame_xml += "<tr " + ("class=\"odd\">" if i % 2 == 1 else ">")
blame_xml += "<td>" + entry[0] + "</td>"
blame_xml += "<td>" + str(entry[1].rows) + "</td>"
blame_xml += "<td>" + "{0:.2f}".format(100.0 * entry[1].comments / entry[1].rows) + "</td>"
blame_xml += "<td style=\"display: none\">" + work_percentage + "</td>"
blame_xml += "</tr>"
chart_data += "{{label: \"{0}\", data: {1}}}".format(entry[0], "{0:.2f}".format(100.0 * entry[1].rows / total_blames))
chart_data += "{{label: \"{0}\", data: {1}}}".format(entry[0], work_percentage)
if blames[-1] != entry:
chart_data += ", "
blame_xml += "<tfoot><tr> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> </tr></tfoot></tbody></table>"
blame_xml += "<tfoot><tr> <td colspan=\"3\">&nbsp;</td> </tr></tfoot></tbody></table>"
blame_xml += "<div class=\"chart\" id=\"blame_chart\"></div></div>"
blame_xml += "<script type=\"text/javascript\">"
blame_xml += " $.plot($(\"#blame_chart\"), [{0}], {{".format(chart_data)
@ -192,7 +195,7 @@ class BlameOutput(Outputable):
blame_xml += " show: true,"
blame_xml += " combine: {"
blame_xml += " threshold: 0.01,"
blame_xml += " label: \"Other Authors\""
blame_xml += " label: \"Minor Authors\""
blame_xml += " }"
blame_xml += " }"
blame_xml += " }"

View file

@ -197,8 +197,7 @@ class ChangesOutput(Outputable):
if sorted(authorinfo_list)[-1] != entry:
chart_data += ", "
changes_xml += ("<tfoot><tr> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td>" +
"</tr></tfoot></tbody></table>")
changes_xml += ("<tfoot><tr> <td colspan=\"5\">&nbsp;</td> </tr></tfoot></tbody></table>")
changes_xml += "<div class=\"chart\" id=\"changes_chart\"></div></div>"
changes_xml += "<script type=\"text/javascript\">"
changes_xml += " $.plot($(\"#changes_chart\"), [{0}], {{".format(chart_data)
@ -208,7 +207,7 @@ class ChangesOutput(Outputable):
changes_xml += " show: true,"
changes_xml += " combine: {"
changes_xml += " threshold: 0.01,"
changes_xml += " label: \"Other Authors\""
changes_xml += " label: \"Minor Authors\""
changes_xml += " }"
changes_xml += " }"
changes_xml += " }"

View file

@ -4,6 +4,49 @@
<script type="application/javascript">{1}</script>
<script type="application/javascript">{2}</script>
<script type="application/javascript">{3}</script>
<script type="application/javascript">
$(document).ready(function() {{
var row = 0;
var MINOR_AUTHOR_PERCENTAGE = 1.00;
var colorRows = function() {{
$(this).removeClass("odd");
if (row++ % 2 == 1) {{
$(this).addClass("odd");
}}
if(this == $(this).parent().find("tr:visible").get(-1)) {{
row = 0;
}}
}}
$("table.git tbody tr td:last-child").filter(function() {{
return parseFloat(this.innerHTML) < MINOR_AUTHOR_PERCENTAGE;
}}).parent().hide();
$("table.git tbody tr:visible").each(colorRows);
$("table.git tfoot tr td:first-child").filter(function() {{
return $(this).parent().parent().parent().find("tbody tr:hidden").length > 0;
}}).each(function() {{
this.innerHTML = "Show minor authors &or;";
}}).hover(function() {{
$(this).addClass("hover");
}}, function() {{
$(this).removeClass("hover");
}}).toggle(function() {{
this.innerHTML = "Hide minor authors &and;";
$(this).parent().parent().parent().find("tbody tr").show().each(colorRows);
}}, function() {{
this.innerHTML = "Show minor authors &or;";
$(this).parent().parent().parent().find("tbody tr td:last-child").filter(function() {{
return parseFloat(this.innerHTML) < MINOR_AUTHOR_PERCENTAGE;
}}).parent().hide();
$("table.git tbody tr:visible").each(colorRows);
}});
}});
</script>
<style type="text/css">
body {{
background: -webkit-linear-gradient(left, #8f8a9a, #dad2d7, #8f8a9a);
@ -60,6 +103,13 @@
table.git tfoot tr td {{
border-radius: 0px 0px 8px 8px;
-moz-border-radius: 0px 0px 8px 8px;
border: 1px solid #eee;
text-align: center;
}}
table.git tfoot tr td.hover {{
background-color: #eddede;
border: 1px solid #bbb;
cursor: hand;
}}
table.git td {{
padding: 0.4em;
@ -85,7 +135,7 @@
right: 0px;
width: 40%;
font-size: x-small;
height: 240px;
max-height: 240px;
}}
p.error {{
color: #700;