Index: cgisetup/models/pgdb.scm ================================================================== --- cgisetup/models/pgdb.scm +++ cgisetup/models/pgdb.scm @@ -201,13 +201,18 @@ (define (pgdb:get-targets-of-type dbh ttype-id target-patt) (dbi:get-rows dbh "SELECT DISTINCT target FROM runs WHERE target LIKE ? AND ttype_id=?;" target-patt ttype-id)) (define (pgdb:get-runs-by-target dbh targets) - (dbi:get-rows dbh "SELECT r.run_name, t.test_name, t.status, t.item_path FROM runs as r INNER JOIN tests AS t ON t.run_id=r.id + (dbi:get-rows dbh "SELECT r.run_name, t.test_name, t.status, t.item_path, t.id, t.rundir, t.final_logf FROM runs as r INNER JOIN tests AS t ON t.run_id=r.id WHERE t.state='COMPLETED' AND r.target like ?;" targets) ) + +(define (pgdb:get-test-by-id dbh id) + (dbi:get-rows dbh "SELECT t.test_name, t.item_path, t.rundir, t.final_logf FROM runs as r INNER JOIN tests AS t ON t.run_id=r.id + WHERE t.id = ?;" id) +) ;;====================================================================== ;; V A R I O U S D A T A M A S S A G E R O U T I N E S ;;====================================================================== ADDED cgisetup/pages/log.scm Index: cgisetup/pages/log.scm ================================================================== --- /dev/null +++ cgisetup/pages/log.scm @@ -0,0 +1,15 @@ +;;====================================================================== +;; Copyright 2017, Matthew Welland. +;; +;; This program is made available under the GNU GPL version 2.0 or +;; greater. See the accompanying file COPYING for details. +;; +;; This program is distributed WITHOUT ANY WARRANTY; without even the +;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +;; PURPOSE. +;;====================================================================== + +(load "models/pgdb.scm") +(include "pages/log_ctrl.scm") +(include "pages/log_view.scm") + ADDED cgisetup/pages/log_ctrl.scm Index: cgisetup/pages/log_ctrl.scm ================================================================== --- /dev/null +++ cgisetup/pages/log_ctrl.scm @@ -0,0 +1,19 @@ +;;====================================================================== +;; Copyright 2017, Matthew Welland. +;; +;; This program is made available under the GNU GPL version 2.0 or +;; greater. See the accompanying file COPYING for details. +;; +;; This program is distributed WITHOUT ANY WARRANTY; without even the +;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +;; PURPOSE. +;;====================================================================== + +;; a function -action is called on POST + +(define (log-action action) + (case (string->symbol action) + ((dosomething) + (dosomething)))) + + ADDED cgisetup/pages/log_view.scm Index: cgisetup/pages/log_view.scm ================================================================== --- /dev/null +++ cgisetup/pages/log_view.scm @@ -0,0 +1,38 @@ +;;====================================================================== +;; Copyright 2017, Matthew Welland. +;; +;; This program is made available under the GNU GPL version 2.0 or +;; greater. See the accompanying file COPYING for details. +;; +;; This program is distributed WITHOUT ANY WARRANTY; without even the +;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +;; PURPOSE. +;;====================================================================== +(define (readlines filename) + (call-with-input-file filename + (lambda (p) + (let loop ((line (read-line p)) + (result '())) + (if (eof-object? line) + (reverse result) + (loop (read-line p) (cons line result))))))) + +(define (pages:log session db shared) + (let* ((dbh (s:db)) + (id (s:get-param 'testid)) + (tests (pgdb:get-test-by-id dbh id))) + + (if (eq? (length tests) 1) + (begin + (s:div 'class "col_12" + (s:fieldset + (conc "Show a runs for Target: " ) + (let* ((test (car tests)) + (html-path (conc (vector-ref test 2) "/" (vector-ref test 3))) + (html-data (readlines html-path))) + (s:p html-data))))) + (begin + (s:div 'class "col_12" + "Log not found"))) +)) + Index: cgisetup/pages/run_view.scm ================================================================== --- cgisetup/pages/run_view.scm +++ cgisetup/pages/run_view.scm @@ -36,15 +36,16 @@ (lambda (col-key) (let ((val (let* ((ht (hash-table-ref/default ordered-runs col-key #f))) (if ht (hash-table-ref/default ht row-key #f))))) (if val (let* ((result (vector-ref val 2)) + (test-id (vector-ref val 4)) (bg (if (equal? result "PASS") "green" "red"))) (s:td 'style (conc "background: " bg ) - (s:a 'href (s:link-to "log" 'target result) + (s:a 'href (s:link-to "log" 'testid test-id) result))) (s:td "")))) a-keys))) b-keys)))))))