Megatest

Check-in [e29acddac8]
Login
Overview
Comment:Fixed typo in cleanup-db
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA1: e29acddac8e8b16c78977dee0a209c530b89026e
User & Date: matt on 2013-07-25 22:32:46
Other Links: branch diff | manifest | tags
Context
2013-07-25
22:36
Added support for comments in .dat files in refdb check-in: d988af5391 user: matt tags: dev
22:32
Fixed typo in cleanup-db check-in: e29acddac8 user: matt tags: dev
20:23
Added MT_ITEMPATH to environments check-in: 5123a2dfc5 user: mrwellan tags: dev
Changes

Modified db.scm from [f1de3bbb19] to [be19e522a9].

476
477
478
479
480
481
482
483

484
485
486
487
488
489
490
491

492
493
494
495
496
497
498
476
477
478
479
480
481
482

483
484
485
486
487
488
489
490

491
492
493
494
495
496
497
498







-
+







-
+







(define (db:clean-up db)
  (let ((count-stmt (sqlite3:prepare db "SELECT (SELECT count(id) FROM tests)+(SELECT count(id) FROM runs);"))
	(statements
	 (map (lambda (stmt)
		(sqlite3:prepare db stmt))
	      (list
	       ;; delete all tests that belong to runs that are 'deleted'
	       "DELETE FROM tests WHERE run_id in (SELECT run_id FROM runs WHERE state='deleted');"
	       "DELETE FROM tests WHERE run_id in (SELECT id FROM runs WHERE state='deleted');"
	       ;; delete all tests that are 'DELETED'
	       "DELETE FROM tests WHERE state='DELETED';"
	       ;; delete all tests that have no run
	       "DELETE FROM tests WHERE run_id NOT IN (SELECT DISTINCT run_id FROM runs);"
	       ;; delete all runs that are state='deleted'
	       "DELETE FROM runs WHERE state='deleted';"
	       ;; delete empty runs
	       ;; "DELETE FROM runs WHERE id NOT IN (SELECT DISTINCT r.id FROM runs AS r INNER JOIN tests AS t ON t.run_id=r.id);"
	       "DELETE FROM runs WHERE id NOT IN (SELECT DISTINCT r.id FROM runs AS r INNER JOIN tests AS t ON t.run_id=r.id);"
	       ))))
    (sqlite3:with-transaction 
     db
     (lambda ()
       (sqlite3:for-each-row (lambda (tot)
			       (debug:print-info 0 "Records count before clean: " tot))
			     count-stmt)