Overview
Comment: | Fix cleanup-db to retain DELETED records for some time. default 30d. configurable via key delete-record-age in setup section |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | v1.65 |
Files: | files | file ages | folders |
SHA1: |
2a51bc466941c8e4cc79a790df3b41f9 |
User & Date: | pjhatwal on 2018-08-24 15:07:34 |
Other Links: | branch diff | manifest | tags |
Context
2018-08-24
| ||
15:57 | Docs update check-in: 33cf143a50 user: mrwellan tags: v1.65, v1.6514 | |
15:07 | Fix cleanup-db to retain DELETED records for some time. default 30d. configurable via key delete-record-age in setup section check-in: 2a51bc4669 user: pjhatwal tags: v1.65 | |
2018-08-23
| ||
18:33 | fix to sync runs independent to changes in tests check-in: 67b2c7d27d user: pjhatwal tags: v1.65 | |
Changes
Modified db.scm from [7a524ea7d5] to [fefb809451].
︙ | ︙ | |||
1722 1723 1724 1725 1726 1727 1728 | ;; b. If test dir gone, delete the test record ;; 2. Look at run records ;; a. If have tests that are not deleted, set state='unknown' ;; b. .... ;; (define (db:clean-up dbdat) ;; (debug:print 0 *default-log-port* "WARNING: db clean up not fully ported to v1.60, cleanup action will be on megatest.db") | > | | | | | | | | > | 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 | ;; b. If test dir gone, delete the test record ;; 2. Look at run records ;; a. If have tests that are not deleted, set state='unknown' ;; b. .... ;; (define (db:clean-up dbdat) ;; (debug:print 0 *default-log-port* "WARNING: db clean up not fully ported to v1.60, cleanup action will be on megatest.db") (let* ((keep-record-age ( - (current-seconds) (common:hms-string->seconds (or (configf:lookup *configdat* "setup" "delete-record-age") "30d")))) (db (db:dbdat-get-db dbdat)) (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' (conc "DELETE FROM tests WHERE run_id in (SELECT id FROM runs WHERE state='deleted') and last_update < " keep-record-age ";") ;; delete all tests that are 'DELETED' (conc "DELETE FROM tests WHERE state='DELETED' and last_update < " keep-record-age " ;") ;; delete all tests that have no run (conc "DELETE FROM tests WHERE run_id NOT IN (SELECT DISTINCT id FROM runs) and last_update < " keep-record-age "; ") ;; delete all runs that are state='deleted' (conc "DELETE FROM runs WHERE state='deleted' and last_update < " keep-record-age ";") ;; delete empty runs (conc "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) and last_update < " keep-record-age ";") ;; remove orphaned test_rundat entries (conc "DELETE FROM test_rundat where test_id NOT IN (SELECT id FROM tests) ;") ;; (conc "DELETE FROM test_steps WHERE test_id NOT IN (SELECT id FROM tests) and last_update < " keep-record-age " ;") )))) ;; (db:delay-if-busy dbdat) ;(debug:print-info 0 *default-log-port* statements) (sqlite3:with-transaction db (lambda () (sqlite3:for-each-row (lambda (tot) (debug:print-info 0 *default-log-port* "Records count before clean: " tot)) count-stmt) (map sqlite3:execute statements) |
︙ | ︙ |