Random Bits of Open Code

Check-in [b6a399e9a9]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixed bad /tmp format bug
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b6a399e9a947e11af64c3f7a04f22db7e97de28a
User & Date: matt 2018-05-21 06:03:59
Context
2018-05-22
05:53
Removed dependency on sql-de-lite in mtcommon. Switched mtdb to sqlite3 from sql-de-lite as it seems to work better. check-in: 36337aa670 user: matt tags: trunk
2018-05-21
06:03
Fixed bad /tmp format bug check-in: b6a399e9a9 user: matt tags: trunk
05:29
Fixed bad /tmp format bug check-in: e398fb41ad user: matt tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to mtutils/mtdb/mtdb.scm.

332
333
334
335
336
337
338


339
340
341
342
343
344
345
...
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
....
1198
1199
1200
1201
1202
1203
1204
1205




1206
1207
1208
1209
1210
1211
1212
	   (dbi:with-transaction
	    dbh
	    (lambda ()
	      (for-each
	       (lambda (stmt)
		 (dbi:exec dbh stmt))
	       *sql-de-lite-schema*))))


       (dbi:exec dbh "PRAGMA journal_mode=WAL")
       (dbi:exec dbh "PRAGMA synchronous=0")
       dbh))

;; do NOT close the db in the following three routines.

;; for sql-de-lite access we keep main and runs in separate files
................................................................................
;;
(define (get-runs-info dbh target-patt run-name-patt area-patt) ;; to join ttype or not?
  (dbi:fold-row
   cons
   '()
   dbh   ;; 0    1       2       3      4     5      6       7        8         9         10          11         12
   "SELECT id,target,ttype_id,run_name,state,status,owner,event_time,comment,fail_count,pass_count,last_update,area_id
       FROM runs WHERE target LIKE ? AND run_name LIKE ? AND area_id IN (SELECT id FROM areas WHERE area_name LIKE ?)
       ORDER BY event_time ASC, id DESC;"
   target-patt run-name-patt area-patt)) ;; note: use ASC because we are cons'ing the data

;;======================================================================
;;  T E S T - S T E P S
;;======================================================================

................................................................................
			   (begin 
			     (print "Inserting test with run-id: " run-id " and test-id: " test-id  " pgdb run id: " pgdb-run-id)
			     (insert-test run-dbh pgdb-run-id test-name item-path state status host cpuload diskfree uname run-dir log-file run-duration comment event-time archived)
			     (set! pgdb-test-id (get-test-id adat2 pgdb-run-id test-name item-path))))
		       (hash-table-set! test-ht test-id pgdb-test-id))))
		 tests))))
	 (print "INFO: sync for run " run-id " completed in " (- (current-seconds) start-time) " seconds.")))
     run-ids)))





;; (use trace)(trace insert-test)(trace-call-sites #t)

(define (add-area-tag dbh area-info tag) 
  (let* ((tag-info (get-tag-info-by-name dbh tag)))
    (if (not tag-info)
	(begin   







>
>







 







|







 







|
>
>
>
>







332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
...
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
....
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
	   (dbi:with-transaction
	    dbh
	    (lambda ()
	      (for-each
	       (lambda (stmt)
		 (dbi:exec dbh stmt))
	       *sql-de-lite-schema*))))
       (case dbtype
	 ((sql-de-lite)(s:set-busy-handler! db (s:busy-timeout 10000))))
       (dbi:exec dbh "PRAGMA journal_mode=WAL")
       (dbi:exec dbh "PRAGMA synchronous=0")
       dbh))

;; do NOT close the db in the following three routines.

;; for sql-de-lite access we keep main and runs in separate files
................................................................................
;;
(define (get-runs-info dbh target-patt run-name-patt area-patt) ;; to join ttype or not?
  (dbi:fold-row
   cons
   '()
   dbh   ;; 0    1       2       3      4     5      6       7        8         9         10          11         12
   "SELECT id,target,ttype_id,run_name,state,status,owner,event_time,comment,fail_count,pass_count,last_update,area_id
       FROM runs WHERE state != 'deleted' AND target LIKE ? AND run_name LIKE ? AND area_id IN (SELECT id FROM areas WHERE area_name LIKE ?)
       ORDER BY event_time ASC, id DESC;"
   target-patt run-name-patt area-patt)) ;; note: use ASC because we are cons'ing the data

;;======================================================================
;;  T E S T - S T E P S
;;======================================================================

................................................................................
			   (begin 
			     (print "Inserting test with run-id: " run-id " and test-id: " test-id  " pgdb run id: " pgdb-run-id)
			     (insert-test run-dbh pgdb-run-id test-name item-path state status host cpuload diskfree uname run-dir log-file run-duration comment event-time archived)
			     (set! pgdb-test-id (get-test-id adat2 pgdb-run-id test-name item-path))))
		       (hash-table-set! test-ht test-id pgdb-test-id))))
		 tests))))
	 (print "INFO: sync for run " run-id " completed in " (- (current-seconds) start-time) " seconds.")))
     run-ids)
    ;; close all database connections - sync can build up a lot of connections
    (close-all-dbs adat1)
    (close-all-dbs adat2)
    ))

;; (use trace)(trace insert-test)(trace-call-sites #t)

(define (add-area-tag dbh area-info tag) 
  (let* ((tag-info (get-tag-info-by-name dbh tag)))
    (if (not tag-info)
	(begin