Repository :
http://git.fedorahosted.org/cgit/jenkinscat-docs.git
On branch : master
---------------------------------------------------------------
commit 38a40f2ef069e5de660ab10f006a72b662f192f3
Author: Pavel Tisnovsky <ptisnovs(a)redhat.com>
Date: Tue Dec 9 13:48:22 2014 +0100
Added 3rd renderer: the one for statistic page.
---------------------------------------------------------------
ChangeLog | 5 +
src/jenkinscat/renderers/statistics_page.clj | 128 ++++++++++++++++++++++++++
2 files changed, 133 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index fdd1bf4..9f77b45 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-12-09 Pavel Tisnovsky <ptisnovs(a)redhat.com>
+
+ * src/jenkinscat/renderers/statistics_page.clj:
+ Added 3rd renderer: the one for statistic page.
+
2014-12-08 Pavel Tisnovsky <ptisnovs(a)redhat.com>
* src/jenkinscat/renderers/add_book_step_2_page.clj:
diff --git a/src/jenkinscat/renderers/statistics_page.clj
b/src/jenkinscat/renderers/statistics_page.clj
new file mode 100644
index 0000000..7066066
--- /dev/null
+++ b/src/jenkinscat/renderers/statistics_page.clj
@@ -0,0 +1,128 @@
+;;;
+;;; Jenkinscat HTTP server that handles all requests send from clients/browsers.
+;;;
+;;; Copyright (c) 2014 Pavel Tisnovsky, Red Hat
+;;; All rights reserved.
+;;;
+;;; Redistribution and use in source and binary forms, with or without
+;;; modification, are permitted provided that the following conditions are met:
+;;; * Redistributions of source code must retain the above copyright
+;;; notice, this list of conditions and the following disclaimer.
+;;; * Redistributions in binary form must reproduce the above copyright
+;;; notice, this list of conditions and the following disclaimer in the
+;;; documentation and/or other materials provided with the distribution.
+;;; * Neither the name of the Red Hat nor the
+;;; names of its contributors may be used to endorse or promote products
+;;; derived from this software without specific prior written permission.
+;;;
+;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND
+;;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+;;; DISCLAIMED. IN NO EVENT SHALL Pavel Tisnovsky BE LIABLE FOR ANY
+;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+;;; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+;;; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+;;; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+;;;
+
+
+
+(ns jenkinscat.renderers.statistics-page)
+
+(require '[hiccup.core :as hiccup])
+(require '[hiccup.page :as page])
+(require '[hiccup.form :as form])
+
+(require '[jenkinscat.renderers.page-header :as page-header-renderer])
+(require '[jenkinscat.renderers.navigation-bar :as navigation-bar-renderer])
+
+(defn- third
+ [coll]
+ (nth coll 2))
+
+(defn render-statistics-page
+ "Render page with various statistics."
+ [statistics]
+ (page/xhtml
+ (page-header-renderer/page-header "statistics")
+ [:body
+ (navigation-bar-renderer/navigation-bar "Statistics")
+ [:table {:class "table table-striped table-condensed table-hover
table-borderer" :style "width:900px"}
+ [:tr
+ [:th {:width "45%"} "Summary"]
+ [:th {:width "20%"} ""]
+ [:th ""]
+ [:th {:width "20%"} ""]
+ ]
+ [:tr
+ [:td "Products:"]
+ [:td (:product-count statistics)]
+ [:th ""]
+ [:th ""]
+ ]
+ [:tr
+ [:td "Books:"]
+ [:td (:book-count statistics)]
+ [:th ""]
+ [:th ""]
+ ]
+ [:tr
+ [:td "Jobs:"]
+ [:td (:job-count statistics)]
+ [:th ""]
+ [:th ""]
+ ]
+ [:tr [:td " "] [:td " "] [:td
" "] [:td " "]]
+ [:tr
+ [:th "Overall pages statistics"]
+ [:th ""]
+ [:th ""]
+ [:th ""]
+ ]
+ [:tr
+ [:td "Total pages:"]
+ [:td (:total-pages statistics)]
+ [:th ""]
+ [:th ""]
+ ]
+ [:tr
+ [:td "Average pages:"]
+ [:td (int (/ (:total-pages statistics) (:book-count statistics)))
" per book"]
+ [:th ""]
+ [:th ""]
+ ]
+ [:tr
+ [:td "Book with max pages"]
+ [:td (:max-pages statistics)]
+ [:td {:colspan 2} (:max-pages-book-name statistics)]
+ ]
+ [:tr
+ [:td "Book with min pages"]
+ [:td (:min-pages statistics)]
+ [:td {:colspan 2} (:min-pages-book-name statistics)]
+ ]
+ [:tr [:td " "] [:td " "] [:td
" "] [:td " "]]
+ [:tr
+ [:th "Statistics per product:"]
+ [:th ""]
+ [:th ""]
+ [:th ""]
+ ]
+ [:tr
+ [:th "Product name"]
+ [:th "Books"]
+ [:th "Total pages"]
+ [:th "Average"]
+ ]
+ (for [stats-for-product (:stats-for-products statistics)]
+ [:tr
+ [:td (first stats-for-product)]
+ [:td (second stats-for-product)]
+ [:td (third stats-for-product)]
+ [:td (if (= 0 (second stats-for-product)) "?" (int (/
(third stats-for-product)(second stats-for-product))))]
+ ])
+
+]]))
+