Index: cgisetup/models/pgdb.scm ================================================================== --- cgisetup/models/pgdb.scm +++ cgisetup/models/pgdb.scm @@ -197,10 +197,11 @@ SUM(CASE WHEN t.status='FAIL' THEN 1 ELSE 0 END) AS fail, SUM(CASE WHEN t.status IN ('PASS','FAIL') THEN 0 ELSE 1 END) AS other FROM tests AS t INNER JOIN runs AS r ON t.run_id=r.id WHERE t.state='COMPLETED' AND r.target LIKE ? GROUP BY r.target;" target-patt)) + (define (pgdb:get-latest-run-stats-given-target dbh ttype-id target-patt) (dbi:get-rows dbh ;; "SELECT COUNT(t.id),t.status,r.target FROM tests AS t INNER JOIN runs AS r ON t.run_id=r.id @@ -227,23 +228,46 @@ FROM tests AS t INNER JOIN runs AS r ON t.run_id=r.id WHERE t.state like '%' AND ttype_id=? AND r.target LIKE ? GROUP BY r.run_name;" ttype-id target-patt )) -(define (pgdb:get-all-run-stats-target-slice dbh target-patt) -(dbi:get-rows - dbh - "SELECT r.target, r.run_name,r.event_time, COUNT(*) AS total, +(define (pgdb:get-all-run-stats-target-slice dbh target-patt limit offset) + (dbi:get-rows + dbh + "SELECT r.target, r.run_name,r.event_time, COUNT(*) AS total, SUM(CASE WHEN t.status='PASS' THEN 1 ELSE 0 END) AS pass, SUM(CASE WHEN t.status='FAIL' THEN 1 ELSE 0 END) AS fail, SUM(CASE WHEN t.status IN ('PASS','FAIL') THEN 0 ELSE 1 END) AS other FROM tests AS t INNER JOIN runs AS r ON t.run_id=r.id WHERE r.target LIKE ? - - GROUP BY r.target,r.run_name, r.event_time;" + GROUP BY r.target,r.run_name, r.event_time + order by r.target,r.event_time desc limit ? offset ? ;" + target-patt limit offset)) + + +(define (pgdb:get-count-data-stats-target-slice dbh target-patt) + (dbi:get-rows + dbh + "SELECT count(*) from (SELECT r.target, r.run_name,r.event_time, COUNT(*) AS total + FROM tests AS t INNER JOIN runs AS r ON t.run_id=r.id + WHERE r.target LIKE ? + GROUP BY r.target,r.run_name, r.event_time + ) as x;" target-patt)) +(define (pgdb:get-slice-cnt dbh target-patt) + (let* ((cnt-result (pgdb:get-count-data-stats-target-slice dbh target-patt)) + ;(cnt-row (car (cnt-result))) + (cnt 0) + ) + (for-each + (lambda (row) + (set! cnt (vector-ref row 0 ))) + cnt-result) + +cnt)) + (define (pgdb:get-target-types dbh) (dbi:get-rows dbh "SELECT id,target_spec FROM ttype;")) (define (pgdb:get-distict-target-slice dbh) @@ -379,5 +403,15 @@ (lambda (run) (let* ((run-name (vector-ref run 0))) (hash-table-set! data run-name run))) runs) data)) + +(define (pgdb:get-pg-lst tab2-pages) + (let loop ((i 1) + (lst `())) + (cond + ((> i tab2-pages ) + lst) + (else + (loop (+ i 1) (append lst (list i))))))) + Index: cgisetup/pages/home_ctrl.scm ================================================================== --- cgisetup/pages/home_ctrl.scm +++ cgisetup/pages/home_ctrl.scm @@ -15,26 +15,30 @@ (case (string->symbol action) ((filter) (let ((target-type (s:get-input 'target-type)) (target-filter (s:get-input 'tfilter)) (target (s:get-input 'target)) - (row-or-col (s:get-input 'row-or-col))) + (row-or-col (s:get-input 'row-or-col))) ;; ;; s:set! is a page local var. Better than s:session-var-set! but still not a good idea. ;; (s:set! "row-or-col" (if (list? row-or-col) (string-intersperse row-or-col ",") row-or-col)) (s:set! "target-type" target-type) (s:set! "tfilter" target-filter) (s:set! "target" target) - (s:set! "target-filter" target-filter))) + (s:set! "target-filter" target-filter) + )) ((filter2) (let ((tslice-select (s:get-input 'tslice-select)) + (page (s:get-input 'page)) (t-slice-filter (s:get-input 't-slice-filter))) ;; ;; s:set! is a page local var. Better than s:session-var-set! but still not a good idea. ;; + ;(s:set! "var" "xyz") (s:set! "tslice" tslice-select) + (s:set! "page" page) (s:set! "t-slice-patt" t-slice-filter))) )) Index: cgisetup/pages/home_view.scm ================================================================== --- cgisetup/pages/home_view.scm +++ cgisetup/pages/home_view.scm @@ -9,28 +9,52 @@ ;; PURPOSE. ;;====================================================================== (define (pages:home session db shared) (let* ((dbh (s:db)) + (tab2-limit 15) + (tab2-page (if (or (equal? (s:get-param "page") "") (equal? (s:get-param "page") #f)) + 1 + (string->number (s:get-param "page")))) + + (tab2-offset (- (* tab2-limit tab2-page) tab2-limit)) (ttypes (pgdb:get-target-types dbh)) (selected (string->number (or (s:get "target-type") "-1"))) (target-slice (pgdb:get-distict-target-slice dbh)) - (selected-slice (or (s:get "tslice") "")) + (selected-slice (if (s:get "tslice") + (s:get "tslice") + (if (s:get-param "tslice") + (s:get-param "tslice") + ""))) (curr-trec (filter (lambda (x)(eq? selected (vector-ref x 0))) ttypes)) (curr-ttype (if (and selected (not (null? curr-trec))) (vector-ref (car curr-trec) 1) #f)) (all-parts (if curr-ttype (append (string-split curr-ttype "/") '("runname" "testname")) '())) + (tfilter (or (s:get "target-filter") "%")) - (tslice-filter (or (s:get "t-slice-patt") "")) + (tslice-filter (if (s:get "t-slice-patt") + (s:get "t-slice-patt") + (if (s:get-param "patt") + (string-substitute "x_x" "%" (s:get-param "patt") 'all) + "%") + )) (target-patt (if (or (equal? selected-slice "") (equal? tslice-filter "" )) "" (conc selected-slice "/" tslice-filter ))) (tab2-data (if (equal? target-patt "") `() - (pgdb:get-all-run-stats-target-slice dbh target-patt))) + (pgdb:get-all-run-stats-target-slice dbh target-patt tab2-limit tab2-offset))) + (tab2-cnt (if (equal? target-patt "") + 0 + (pgdb:get-slice-cnt dbh target-patt))) + + (tab2-pages (round (/ tab2-cnt tab2-limit))) + (tab2-page-lst (pgdb:get-pg-lst tab2-pages)) + (tab2-ordered-data (pgdb:coalesce-runs-by-slice tab2-data selected-slice)) + (targets (pgdb:get-targets-of-type dbh selected tfilter)) (row-or-col (string-split (or (s:get "row-or-col") "") ",")) (all-data (if (and selected (not (eq? selected -1))) (pgdb:get-latest-run-stats-given-target dbh selected tfilter) @@ -45,11 +69,11 @@ (s:li (s:a 'href "#tabr2" "Genral Filter"))) (s:div 'id "tabr1" 'class "tab-content" (s:div 'class "col_11" (s:fieldset "Filter Targets by slice" (s:form - 'action "home.filter2" 'method "post" + 'action "home.filter2" 'method "post" 'name "form1" (s:div 'class "col_12" (s:div 'class "col_6" (s:select (map (lambda (x) (let ((t-slice (vector-ref x 0))) (if (equal? t-slice selected-slice) @@ -56,14 +80,20 @@ (list t-slice t-slice t-slice #t) (list t-slice t-slice t-slice #f)))) target-slice) 'name 'tslice-select)) (s:div 'class "col_4" - (s:input-preserve 'name "t-slice-filter" 'placeholder "Filter remainder target")) + (s:input 'type "text" 'name "t-slice-filter" 'value tslice-filter)) (s:div 'class "col_2" (s:input 'type "submit" 'name "set-filter-vals" 'value "Submit"))))) - (s:br) + (s:br) + ; (s:p (conc tslice-filter selected-slice tab2-page)) + (s:p (map + (lambda (i) + (s:span (s:a 'href (s:link-to "home" 'page i 'patt (string-substitute "%" "x_x" tslice-filter 'all) 'tslice selected-slice) "PAGE " i )" | ")) + tab2-page-lst)) + (s:p "  Result Format:   total / pass / fail / other") (s:fieldset (conc "Runs data for " target-patt) (let* ((target-keys (hash-table-keys tab2-ordered-data)) (run-keys (delete-duplicates (apply append (map (lambda (sub-key) (let ((subdat (hash-table-ref tab2-ordered-data sub-key))) Index: cgisetup/pages/index.scm ================================================================== --- cgisetup/pages/index.scm +++ cgisetup/pages/index.scm @@ -8,9 +8,10 @@ ;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ;; PURPOSE. ;;====================================================================== (use regex) + ;; (load "models/pgdb.scm") -(include "pages/index_ctrl.scm") -(include "pages/index_view.scm") +(include "pages/index_ctrl.scm") +(include "pages/index_view.scm")