@@ -460,10 +460,38 @@ (db:set-var db "MEGATEST_VERSION" 1.37) (sqlite3:execute db "ALTER TABLE tests ADD COLUMN archived INTEGER DEFAULT 0;")) ((< mver megatest-version) (db:set-var db "MEGATEST_VERSION" megatest-version)))))) +;;====================================================================== +;; M A I N T E N A N C E +;;====================================================================== + +(define (db:find-and-mark-incomplete db) + (let ((incompleted '())) + (sqlite3:for-each-row + (lambda (test-id) + (set! incompleted (cons test-id incompleted))) + db + "SELECT id FROM tests WHERE event_time (length incompleted) 0) + (begin + (debug:print 0 "WARNING: Marking test(s); " (string-intersperse (map conc incompleted) ", ") " as INCOMPLETE") + (sqlite3:execute + db + (conc "UPDATE tests SET state='INCOMPLETE' WHERE id IN (" + (string-intersperse (map conc incompleted) ",") + ");")))))) + ;; Clean out old junk and vacuum the database ;; ;; Ultimately do something like this: ;; ;; 1. Look at test records either deleted or part of deleted run: @@ -500,10 +528,11 @@ (sqlite3:for-each-row (lambda (tot) (debug:print-info 0 "Records count after clean: " tot)) count-stmt))) (map sqlite3:finalize! statements) (sqlite3:finalize! count-stmt) + (db:find-and-mark-incomplete db) (sqlite3:execute db "VACUUM;"))) ;; (define (db:report-junk-records db)