Index: runs.scm ================================================================== --- runs.scm +++ runs.scm @@ -2560,67 +2560,10 @@ (lambda (test-name) (let* ((test-conf (mt:lazy-read-test-config test-name))) (if test-conf (runs:update-test_meta test-name test-conf)))) (hash-table-keys test-names)))) -;; This could probably be refactored into one complex query ... -;; NOT PORTED - DO NOT USE YET -;; -(define (runs:rollup-run keys runname user keyvals) - (debug:print 4 *default-log-port* "runs:rollup-run, keys: " keys " -runname " runname " user: " user) - (let* ((db #f) - ;; register run operates on the main db - (new-run-id (rmt:register-run keyvals runname "new" "n/a" user (args:get-arg "-contour"))) - (prev-tests (rmt:get-matching-previous-test-run-records new-run-id "%" "%")) - (curr-tests (mt:get-tests-for-run new-run-id "%/%" '() '())) - (curr-tests-hash (make-hash-table))) - (rmt:update-run-event_time new-run-id) - ;; index the already saved tests by testname and itemdat in curr-tests-hash - (for-each - (lambda (testdat) - (let* ((testname (db:test-get-testname testdat)) - (item-path (db:test-get-item-path testdat)) - (full-name (conc testname "/" item-path))) - (hash-table-set! curr-tests-hash full-name testdat))) - curr-tests) - ;; NOPE: Non-optimal approach. Try this instead. - ;; 1. tests are received in a list, most recent first - ;; 2. replace the rollup test with the new *always* - (for-each - (lambda (testdat) - (let* ((testname (db:test-get-testname testdat)) - (item-path (db:test-get-item-path testdat)) - (full-name (conc testname "/" item-path)) - (prev-test-dat (hash-table-ref/default curr-tests-hash full-name #f)) - (test-steps (rmt:get-steps-for-test (db:test-get-id testdat))) - (new-test-record #f)) - ;; replace these with insert ... select - (apply sqlite3:execute - db - (conc "INSERT OR REPLACE INTO tests (run_id,testname,state,status,event_time,host,cpuload,diskfree,uname,rundir,item_path,run_duration,final_logf,comment) " - "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?);") - new-run-id (cddr (vector->list testdat))) - (set! new-testdat (car (mt:get-tests-for-run new-run-id (conc testname "/" item-path) '() '()))) - (hash-table-set! curr-tests-hash full-name new-testdat) ;; this could be confusing, which record should go into the lookup table? - ;; Now duplicate the test steps - (debug:print 4 *default-log-port* "Copying records in test_steps from test_id=" (db:test-get-id testdat) " to " (db:test-get-id new-testdat)) - (cdb:remote-run ;; to be replaced, note: this routine is not used currently - (lambda () - (sqlite3:execute - db - (conc "INSERT OR REPLACE INTO test_steps (test_id,stepname,state,status,event_time,comment) " - "SELECT " (db:test-get-id new-testdat) ",stepname,state,status,event_time,comment FROM test_steps WHERE test_id=?;") - (db:test-get-id testdat)) - ;; Now duplicate the test data - (debug:print 4 *default-log-port* "Copying records in test_data from test_id=" (db:test-get-id testdat) " to " (db:test-get-id new-testdat)) - (sqlite3:execute - db - (conc "INSERT OR REPLACE INTO test_data (test_id,category,variable,value,expected,tol,units,comment) " - "SELECT " (db:test-get-id new-testdat) ",category,variable,value,expected,tol,units,comment FROM test_data WHERE test_id=?;") - (db:test-get-id testdat)))) - )) - prev-tests))) ;; clean cache files (define (runs:clean-cache target runname toppath) (if target @@ -2642,5 +2585,67 @@ (debug:print 0 *default-log-port* "WARNING: Failed to remove file " f) (delete-file f))) files)))) (debug:print-error 0 *default-log-port* "-clean-cache requires -runname.")) (debug:print-error 0 *default-log-port* "-clean-cache requires -target or -reqtarg"))) + +;;====================================================================== +;; DEFUNCT +;;====================================================================== + +;;==remove me==;; This could probably be refactored into one complex query ... +;;==remove me==;; NOT PORTED - DO NOT USE YET +;;==remove me==;; +;;==remove me==(define (runs:rollup-run keys runname user keyvals) +;;==remove me== (debug:print 4 *default-log-port* "runs:rollup-run, keys: " keys " -runname " runname " user: " user) +;;==remove me== (let* ((db #f) +;;==remove me== ;; register run operates on the main db +;;==remove me== (new-run-id (rmt:register-run keyvals runname "new" "n/a" user (args:get-arg "-contour"))) +;;==remove me== (prev-tests (rmt:get-matching-previous-test-run-records new-run-id "%" "%")) +;;==remove me== (curr-tests (mt:get-tests-for-run new-run-id "%/%" '() '())) +;;==remove me== (curr-tests-hash (make-hash-table))) +;;==remove me== (rmt:update-run-event_time new-run-id) +;;==remove me== ;; index the already saved tests by testname and itemdat in curr-tests-hash +;;==remove me== (for-each +;;==remove me== (lambda (testdat) +;;==remove me== (let* ((testname (db:test-get-testname testdat)) +;;==remove me== (item-path (db:test-get-item-path testdat)) +;;==remove me== (full-name (conc testname "/" item-path))) +;;==remove me== (hash-table-set! curr-tests-hash full-name testdat))) +;;==remove me== curr-tests) +;;==remove me== ;; NOPE: Non-optimal approach. Try this instead. +;;==remove me== ;; 1. tests are received in a list, most recent first +;;==remove me== ;; 2. replace the rollup test with the new *always* +;;==remove me== (for-each +;;==remove me== (lambda (testdat) +;;==remove me== (let* ((testname (db:test-get-testname testdat)) +;;==remove me== (item-path (db:test-get-item-path testdat)) +;;==remove me== (full-name (conc testname "/" item-path)) +;;==remove me== (prev-test-dat (hash-table-ref/default curr-tests-hash full-name #f)) +;;==remove me== (test-steps (rmt:get-steps-for-test (db:test-get-id testdat))) +;;==remove me== (new-test-record #f)) +;;==remove me== ;; replace these with insert ... select +;;==remove me== (apply sqlite3:execute +;;==remove me== db +;;==remove me== (conc "INSERT OR REPLACE INTO tests (run_id,testname,state,status,event_time,host,cpuload,diskfree,uname,rundir,item_path,run_duration,final_logf,comment) " +;;==remove me== "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?);") +;;==remove me== new-run-id (cddr (vector->list testdat))) +;;==remove me== (set! new-testdat (car (mt:get-tests-for-run new-run-id (conc testname "/" item-path) '() '()))) +;;==remove me== (hash-table-set! curr-tests-hash full-name new-testdat) ;; this could be confusing, which record should go into the lookup table? +;;==remove me== ;; Now duplicate the test steps +;;==remove me== (debug:print 4 *default-log-port* "Copying records in test_steps from test_id=" (db:test-get-id testdat) " to " (db:test-get-id new-testdat)) +;;==remove me== (cdb:remote-run ;; to be replaced, note: this routine is not used currently +;;==remove me== (lambda () +;;==remove me== (sqlite3:execute +;;==remove me== db +;;==remove me== (conc "INSERT OR REPLACE INTO test_steps (test_id,stepname,state,status,event_time,comment) " +;;==remove me== "SELECT " (db:test-get-id new-testdat) ",stepname,state,status,event_time,comment FROM test_steps WHERE test_id=?;") +;;==remove me== (db:test-get-id testdat)) +;;==remove me== ;; Now duplicate the test data +;;==remove me== (debug:print 4 *default-log-port* "Copying records in test_data from test_id=" (db:test-get-id testdat) " to " (db:test-get-id new-testdat)) +;;==remove me== (sqlite3:execute +;;==remove me== db +;;==remove me== (conc "INSERT OR REPLACE INTO test_data (test_id,category,variable,value,expected,tol,units,comment) " +;;==remove me== "SELECT " (db:test-get-id new-testdat) ",category,variable,value,expected,tol,units,comment FROM test_data WHERE test_id=?;") +;;==remove me== (db:test-get-id testdat)))) +;;==remove me== )) +;;==remove me== prev-tests)))