Megatest

Check-in [f26494345d]
Login
Overview
Comment:Fixed sorting
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.55
Files: files | file ages | folders
SHA1: f26494345dfa5dc47dbc0c05e2dc05e90723ab82
User & Date: mrwellan on 2013-08-20 11:30:32
Other Links: branch diff | manifest | tags
Context
2013-08-22
09:28
Merged change made on dev that fixes the messy sort view issue check-in: a0cf2c468e user: mrwellan tags: v1.55
00:21
Re-fixed sorting to handle partial runs alongside full runs check-in: 2f78c46ed6 user: matt tags: dev
2013-08-20
11:30
Fixed sorting check-in: f26494345d user: mrwellan tags: v1.55
00:20
Commented out tweak for better sort logic, look in bubble-up check-in: 7f93bdaf46 user: matt tags: v1.55
Changes

Modified dashboard.scm from [821e96c24e] to [c37f1382a1].

151
152
153
154
155
156
157



158
159
160
161
162
163
164
;; Don't forget to adjust the >= below if you add to the sort-options above
(define (next-sort-option)
  (if (>= *tests-sort-reverse* 5)
      (set! *tests-sort-reverse* 0)
      (set! *tests-sort-reverse* (+ *tests-sort-reverse* 1)))
  *tests-sort-reverse*)




(define *tests-sort-reverse* 0)
(define *hide-empty-runs* #f)

(define *current-tab-number* 0)
(define *updaters* (make-hash-table))

(debug:setup)







>
>
>







151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
;; Don't forget to adjust the >= below if you add to the sort-options above
(define (next-sort-option)
  (if (>= *tests-sort-reverse* 5)
      (set! *tests-sort-reverse* 0)
      (set! *tests-sort-reverse* (+ *tests-sort-reverse* 1)))
  *tests-sort-reverse*)

(define (get-curr-sort)
  (vector-ref *tests-sort-options* *tests-sort-reverse*))

(define *tests-sort-reverse* 0)
(define *hide-empty-runs* #f)

(define *current-tab-number* 0)
(define *updaters* (make-hash-table))

(debug:setup)
209
210
211
212
213
214
215
216
217
218
219
220




221
222
223
224
225
226
227
228
	 (states      (hash-table-keys *state-ignore-hash*))
	 (statuses    (hash-table-keys *status-ignore-hash*)))
    ;; 
    ;; trim runs to only those that are changing often here
    ;; 
    (for-each (lambda (run)
		(let* ((run-id     (db:get-value-by-header run header "id"))
		       (sort-info  (vector-ref *tests-sort-options* *tests-sort-reverse*))
		       (sort-by    (vector-ref sort-info 1))
		       (sort-order (vector-ref sort-info 2))
		       (tmptests   (mt:get-tests-for-run run-id testnamepatt states statuses sort-by: sort-by sort-order: sort-order))
		       ;; NOTE: bubble-up also sets the global *all-item-test-names*




		       (tests      (bubble-up tmptests))
		       (key-vals   (cdb:remote-run db:get-key-vals #f run-id)))
		  ;; Not sure this is needed?
		  (set! referenced-run-ids (cons run-id referenced-run-ids))
		  (if (> (length tests) maxtests)
		      (set! maxtests (length tests)))
		  (if (or (not *hide-empty-runs*) ;; this reduces the data burden when set
			  (not (null? tests)))







|




>
>
>
>
|







212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
	 (states      (hash-table-keys *state-ignore-hash*))
	 (statuses    (hash-table-keys *status-ignore-hash*)))
    ;; 
    ;; trim runs to only those that are changing often here
    ;; 
    (for-each (lambda (run)
		(let* ((run-id     (db:get-value-by-header run header "id"))
		       (sort-info  (get-curr-sort))
		       (sort-by    (vector-ref sort-info 1))
		       (sort-order (vector-ref sort-info 2))
		       (tmptests   (mt:get-tests-for-run run-id testnamepatt states statuses sort-by: sort-by sort-order: sort-order))
		       ;; NOTE: bubble-up also sets the global *all-item-test-names*
		       (bubble-type (if (member sort-order '(testname))
					'testname
					'itempath
					))
		       (tests      (bubble-up tmptests priority: bubble-type))
		       (key-vals   (cdb:remote-run db:get-key-vals #f run-id)))
		  ;; Not sure this is needed?
		  (set! referenced-run-ids (cons run-id referenced-run-ids))
		  (if (> (length tests) maxtests)
		      (set! maxtests (length tests)))
		  (if (or (not *hide-empty-runs*) ;; this reduces the data burden when set
			  (not (null? tests)))
311
312
313
314
315
316
317











318
319
320
321
322
323
324
325
326

327
328
329
330
331
332
333
334
335
336
337

338
339
340
341
342
343
344
345
				(if (> (length parts) 1)(conc "  " (car (string-split (cadr parts) ")"))) newval))))
	      (vector-set! keycol i newval)
	      (iup:attribute-set! lbl "TITLE" munged-val)))
	(iup:attribute-set! lbl "FGCOLOR" (if (hash-table-ref/default *collapsed* newval #f) "0 112 112" "0 0 0"))
	(if (< i maxn)
	    (loop (+ i 1)))))))












;; Bubble up the top tests to above the items, collect the items underneath
;; all while preserving the sort order from the SQL query as best as possible.
;;
(define (bubble-up test-dats #!key (priority 'itempath))
  (if (null? test-dats)
      test-dats
      (begin
	(let* ((tnames '())                ;; list of names used to reserve order
	       (tests  (make-hash-table))) ;; hash of lists, used to build as we go

	  (for-each 
	   (lambda (testdat)
	     (let* ((tname (db:test-get-testname testdat))
		    (ipath (db:test-get-item-path testdat))
		    (seen  (hash-table-ref/default tests tname #f)))
	       (if (not seen)
		   (set! tnames (append tnames (list tname))))
;;		   (if (or (and (eq? priority 'itempath)
;;				(not (equal? ipath "")))
;;			   (and (eq? priority 'testname)
;;				(equal? ipath "")))

;;		       (set! tnames (append tnames (list tname)))))
	       (if (equal? ipath "")
		   ;; This a top level, prepend it
		   (hash-table-set! tests tname (cons testdat (hash-table-ref/default tests tname '())))
		   ;; This is item, append it
		   (hash-table-set! tests tname (append (hash-table-ref/default tests tname '())(list testdat))))))
	   test-dats)
	;; Set all tests with items 







>
>
>
>
>
>
>
>
>
>
>








|
>



|
|
|
<
|
|
|
|
>
|







318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351

352
353
354
355
356
357
358
359
360
361
362
363
364
				(if (> (length parts) 1)(conc "  " (car (string-split (cadr parts) ")"))) newval))))
	      (vector-set! keycol i newval)
	      (iup:attribute-set! lbl "TITLE" munged-val)))
	(iup:attribute-set! lbl "FGCOLOR" (if (hash-table-ref/default *collapsed* newval #f) "0 112 112" "0 0 0"))
	(if (< i maxn)
	    (loop (+ i 1)))))))


(define (get-itemized-tests test-dats)
  (let ((tnames '()))
    (for-each (lambda (tdat)
		(let ((tname (db:test-get-testname tdat))
		      (ipath (db:test-get-item-path tdat)))
		  (if (not (equal? ipath ""))
		      (if (not (member tname tnames))
			  (set! tnames (append tnames (list tname)))))))
	      test-dats)))

;; Bubble up the top tests to above the items, collect the items underneath
;; all while preserving the sort order from the SQL query as best as possible.
;;
(define (bubble-up test-dats #!key (priority 'itempath))
  (if (null? test-dats)
      test-dats
      (begin
	(let* ((tnames '())                ;; list of names used to reserve order
	       (tests  (make-hash-table))  ;; hash of lists, used to build as we go
	       (itemized (get-itemized-tests test-dats)))
	  (for-each 
	   (lambda (testdat)
	     (let* ((tname (db:test-get-testname testdat))
		    (ipath (db:test-get-item-path testdat)))
	       ;;   (seen  (hash-table-ref/default tests tname #f)))
	       (if (not (member tname tnames))

		   (if (or (and (eq? priority 'itempath)
				(not (equal? ipath "")))
			   (and (eq? priority 'testname)
				(equal? ipath ""))
			   (not (member tname itemized)))
		       (set! tnames (append tnames (list tname)))))
	       (if (equal? ipath "")
		   ;; This a top level, prepend it
		   (hash-table-set! tests tname (cons testdat (hash-table-ref/default tests tname '())))
		   ;; This is item, append it
		   (hash-table-set! tests tname (append (hash-table-ref/default tests tname '())(list testdat))))))
	   test-dats)
	;; Set all tests with items 

Modified db.scm from [acd9ed7d63] to [e7de2918f8].

942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
	 (tests-match-qry (tests:match->sqlqry testpatt))
	 (qry             (conc "SELECT " qryvals
				" FROM tests WHERE run_id=? AND state != 'DELETED' "
				states-statuses-qry
				(if tests-match-qry (conc " AND (" tests-match-qry ") ") "")
				(case sort-by
				  ((rundir)      " ORDER BY length(rundir) ")
				  ((testname)    " ORDER BY testname,item_path ")
				  ((statestatus) " ORDER BY state,status ")
				  ((event_time)  " ORDER BY event_time ")
				  (else          (if (string? sort-by)
						     (conc " ORDER BY " sort-by)
						     "")))
				(if sort-order sort-order "")
				(if limit  (conc " LIMIT " limit)   "")
				(if offset (conc " OFFSET " offset) "")







|
|







942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
	 (tests-match-qry (tests:match->sqlqry testpatt))
	 (qry             (conc "SELECT " qryvals
				" FROM tests WHERE run_id=? AND state != 'DELETED' "
				states-statuses-qry
				(if tests-match-qry (conc " AND (" tests-match-qry ") ") "")
				(case sort-by
				  ((rundir)      " ORDER BY length(rundir) ")
				  ((testname)    (conc " ORDER BY testname " (if sort-order (conc sort-order ",") "") " item_path "))
				  ((statestatus) (conc " ORDER BY state " (if  sort-order (conc sort-order ",") "") " status "))
				  ((event_time)  " ORDER BY event_time ")
				  (else          (if (string? sort-by)
						     (conc " ORDER BY " sort-by)
						     "")))
				(if sort-order sort-order "")
				(if limit  (conc " LIMIT " limit)   "")
				(if offset (conc " OFFSET " offset) "")