aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2013-11-22 22:52:03 +0000
committerRob Austein <sra@hactrn.net>2013-11-22 22:52:03 +0000
commit72a0dcb9ee25aca63028402a9fca04ed4c2f4ad6 (patch)
tree25fcad31b888adc5e13336f009655286d746f574
parent093f08e9a4da6dc356238f1f2dc482d5977eb151 (diff)
Add object count table, per ancient request from Keyur. See #10.
svn path=/trunk/; revision=5602
-rw-r--r--rcynic/rcynic-html.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/rcynic/rcynic-html.py b/rcynic/rcynic-html.py
index 46e2e634..e872aa54 100644
--- a/rcynic/rcynic-html.py
+++ b/rcynic/rcynic-html.py
@@ -37,6 +37,7 @@ opt = {
"refresh" : 1800,
"show-problems" : True,
"show-graphs" : True,
+ "show-object-counts" : True,
"update-rrds" : True,
"png-height" : 190,
"png-width" : 1350,
@@ -584,6 +585,31 @@ class HTML(object):
td.text = str(count)
return table
+ def object_count_table(self, session):
+ table = self.BodyElement("table", rules = "all", border = "1")
+ thead = SubElement(table, "thead")
+ tbody = SubElement(table, "tbody")
+ tfoot = SubElement(table, "tfoot")
+ fn2s = [fn2 for fn2 in session.fn2s if fn2 is not None]
+ total = dict((fn2, 0) for fn2 in fn2s)
+ for hostname in session.hostnames:
+ tr = SubElement(tbody, "tr")
+ SubElement(tr, "td").text = hostname
+ for fn2 in fn2s:
+ td = SubElement(tr, "td")
+ count = sum(uri.endswith(fn2) for uri in session.hosts[hostname].uris)
+ total[fn2] += count
+ if count > 0:
+ td.text = str(count)
+ trhead = SubElement(thead, "tr")
+ trfoot = SubElement(tfoot, "tr")
+ SubElement(trhead, "th").text = "Repository"
+ SubElement(trfoot, "td").text = "Total"
+ for fn2 in fn2s:
+ SubElement(trhead, "th").text = fn2
+ SubElement(trfoot, "td").text = str(total[fn2])
+ return table
+
def detail_table(self, records):
if records:
table = self.BodyElement("table", rules = "all", border = "1")
@@ -632,6 +658,12 @@ def main():
html = HTML("rcynic summary", "index")
html.BodyElement("h2").text = "Grand totals for all repositories"
html.counter_table(session.get_sum, Label.get_count)
+ if opt["show-object-counts"]:
+ html.BodyElement("br")
+ html.BodyElement("hr")
+ html.BodyElement("br")
+ html.BodyElement("h2").text = "Current total object counts (distinct URIs)"
+ html.object_count_table(session)
for hostname in session.hostnames:
html.BodyElement("br")
html.BodyElement("hr")