@@ -431,11 +431,14 @@ ;; states and statuses are lists, turn them into ("PASS","FAIL"...) and use NOT IN ;; i.e. these lists define what to NOT show. ;; states and statuses are required to be lists, empty is ok ;; not-in #t = above behaviour, #f = must match -(define (db:get-tests-for-run db run-id testpatt itempatt states statuses #!key (not-in #t)) +(define (db:get-tests-for-run db run-id testpatt itempatt states statuses + #!key (not-in #t) + (sort-by #f) ;; 'rundir 'event_time + ) (let* ((res '()) ;; if states or statuses are null then assume match all when not-in is false (states-str (conc " state in ('" (string-intersperse states "','") "')")) (statuses-str (conc " status in ('" (string-intersperse statuses "','") "')")) (state-status-qry (if (or (not (null? states)) @@ -443,12 +446,14 @@ (conc " AND " (if not-in "NOT" "") " (" states-str " AND " statuses-str ") ") "")) (qry (conc "SELECT id,run_id,testname,state,status,event_time,host,cpuload,diskfree,uname,rundir,item_path,run_duration,final_logf,comment " " FROM tests WHERE run_id=? AND testname like ? AND item_path LIKE ? " state-status-qry - ;; " ORDER BY id DESC;" - " ORDER BY event_time ASC;" ;; POTENTIAL ISSUE! CHECK ME! Does anyting depend on this being sorted by id? + (case sort-by + ((rundir) " ORDER BY length(rundir) DESC;") + ((event_time) " ORDER BY event_time ASC;") + (else ";")) ))) (debug:print 8 "INFO: db:get-tests-for-run qry=" qry) (sqlite3:for-each-row (lambda (a . b) ;; id run-id testname state status event-time host cpuload diskfree uname rundir item-path run-duration final-logf comment) (set! res (cons (apply vector a b) res))) ;; id run-id testname state status event-time host cpuload diskfree uname rundir item-path run-duration final-logf comment) res)))