Random Bits of Open Code

Check-in [ef7a0d02fc]
Login

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

Overview
Comment:Added get-mindata
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:ef7a0d02fc8a6023319dacef0755f01e212ea6d4
User & Date: matt 2018-05-01 23:44:57
Context
2018-05-02
06:06
Added megatest colors support to iuputils (as good a place as any). check-in: 772dfc1869 user: matt tags: trunk, worked-at-home
2018-05-01
23:44
Added get-mindata check-in: ef7a0d02fc user: matt tags: trunk
07:36
Capture area-ids into adat structs check-in: 7ac36960b6 user: matt tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to mtutils/mtdb/mtdb.scm.

67
68
69
70
71
72
73


74
75
76
77
78
79
80
..
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
...
591
592
593
594
595
596
597







598
599
600
601
602
603
604
...
623
624
625
626
627
628
629


630
631
632
633
634
635
636
637









638
639
640
641
642
643
644
     get-runs-info
     insert-run
     get-run-name-from-id

     ;; tests
     get-test-info-by-id
     get-test-id


     
     ;; misc queries
     get-changed-record-ids
     ;; data structs - there must be an easy way to do this?
     ;; Megatest 1.X stuff
     get-run-info-1.X
     get-header
................................................................................
     version-signature
     get-last-run-version
     get-last-run-version-number
     set-last-run-version
 
     )

(import scheme chicken data-structures extras ports srfi-69 srfi-1 matchable)
(use regex
     (prefix sql-de-lite s:)
     (prefix dbi dbi:) posix typed-records
     (prefix mtcommon common:)
     (prefix mtconfigf configf:))

;; (use trace)

................................................................................
         test_id=?, category=?, variable=?, value=?, expected=?, tol=?, units=?, comment=?, status=?, type=?
          WHERE id=?;"
   test-id category variable value expected tol units comment status type data-id ))

;;======================================================================
;;  T E S T S
;;======================================================================








;; given run-id, test_name and item_path return test-id
;;
(define (get-test-id adat run-id test-name item-path)
  (let ((run-dbh (with-run-db adat #f run-id)))
    (dbi:get-one
     run-dbh
................................................................................
   "UPDATE tests SET
      run_id=?,test_name=?,item_path=?,state=?,status=?,host=?,cpuload=?,diskfree=?,uname=?,rundir=?,final_logf=?,run_duration=?,comment=?,event_time=?,archived=?
    WHERE id=?;"

   run-id  test-name item-path    state   status     host  cpuload diskfree uname
   run-dir log-file  run-duration comment event-time archived test-id))



(define (get-tests dbh target-patt)
  (dbi:get-rows
   dbh
   "SELECT t.id,t.run_id,t.test_name,t.item_path,t.state,t.status,t.host,t.cpuload,t.diskfree,t.uname,t.rundir,t.final_logf,t.run_duration,t.comment,t.event_time,t.archived,
           r.id,r.target,r.ttype_id,r.run_name,r.state,r.status,r.owner,r.event_time,r.comment
     FROM tests AS t INNER JOIN runs AS r ON t.run_id=r.id
      WHERE r.target LIKE ?;" target-patt))










;;======================================================================
;; T E S T   D A T A 
;;======================================================================

;; FOR 2.0 THIS MUST BE CALLED ON CORRECT run-id.db
;;
(define (get-data-info-by-id dbh test-data-id)







>
>







 







|
|







 







>
>
>
>
>
>
>







 







>
>
|







>
>
>
>
>
>
>
>
>







67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
...
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
...
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
...
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
     get-runs-info
     insert-run
     get-run-name-from-id

     ;; tests
     get-test-info-by-id
     get-test-id
     full-name
     get-tests-mindata
     
     ;; misc queries
     get-changed-record-ids
     ;; data structs - there must be an easy way to do this?
     ;; Megatest 1.X stuff
     get-run-info-1.X
     get-header
................................................................................
     version-signature
     get-last-run-version
     get-last-run-version-number
     set-last-run-version
 
     )

(import scheme chicken data-structures extras ports srfi-69 srfi-1)
(use regex srfi-13 matchable
     (prefix sql-de-lite s:)
     (prefix dbi dbi:) posix typed-records
     (prefix mtcommon common:)
     (prefix mtconfigf configf:))

;; (use trace)

................................................................................
         test_id=?, category=?, variable=?, value=?, expected=?, tol=?, units=?, comment=?, status=?, type=?
          WHERE id=?;"
   test-id category variable value expected tol units comment status type data-id ))

;;======================================================================
;;  T E S T S
;;======================================================================

;; given test-name and item-path return fullname
;;
(define (full-name test-name item-path)
  (if (string-null? item-path)
      test-name
      (conc test-name "/" item-path)))

;; given run-id, test_name and item_path return test-id
;;
(define (get-test-id adat run-id test-name item-path)
  (let ((run-dbh (with-run-db adat #f run-id)))
    (dbi:get-one
     run-dbh
................................................................................
   "UPDATE tests SET
      run_id=?,test_name=?,item_path=?,state=?,status=?,host=?,cpuload=?,diskfree=?,uname=?,rundir=?,final_logf=?,run_duration=?,comment=?,event_time=?,archived=?
    WHERE id=?;"

   run-id  test-name item-path    state   status     host  cpuload diskfree uname
   run-dir log-file  run-duration comment event-time archived test-id))

;; DOESNT WORK WITH 2.0 DB
;;
(define (get-tests-by-target dbh target-patt)
  (dbi:get-rows
   dbh
   "SELECT t.id,t.run_id,t.test_name,t.item_path,t.state,t.status,t.host,t.cpuload,t.diskfree,t.uname,t.rundir,t.final_logf,t.run_duration,t.comment,t.event_time,t.archived,
           r.id,r.target,r.ttype_id,r.run_name,r.state,r.status,r.owner,r.event_time,r.comment
     FROM tests AS t INNER JOIN runs AS r ON t.run_id=r.id
      WHERE r.target LIKE ?;" target-patt))

;; Get minimal data for tests given a run-id
;;
(define (get-tests-mindata dbh)
  (dbi:fold-row
   cons
   '()
   dbh   ;; 0    1         2        3     4          5          6        7
   "SELECT id,test_name,item_path,state,status,run_duration,event_time,archived FROM tests ORDER BY event_time DESC;"))

;;======================================================================
;; T E S T   D A T A 
;;======================================================================

;; FOR 2.0 THIS MUST BE CALLED ON CORRECT run-id.db
;;
(define (get-data-info-by-id dbh test-data-id)