diff options
author | Clément Lassieur <clement@lassieur.org> | 2018-07-20 10:50:48 +0200 |
---|---|---|
committer | Clément Lassieur <clement@lassieur.org> | 2018-07-30 00:26:31 +0200 |
commit | 99241ef1af24cadf39e3cad39f9ff27c96b22068 (patch) | |
tree | 70fe49350cc8f232ae886565137f8359c34d6d24 /src/cuirass/database.scm | |
parent | 675cd04a8530fdc16f68758a410b91ce10d46b18 (diff) | |
download | cuirass-99241ef1af24cadf39e3cad39f9ff27c96b22068.tar cuirass-99241ef1af24cadf39e3cad39f9ff27c96b22068.tar.gz |
http: Change the paramater format from two-elements lists to pairs.
* src/cuirass/database.scm (assqx-ref): Remove exported procedure.
(db-get-builds, db-get-build): Adapt to new format.
* src/cuirass/http.scm (request-parameters): Use (cons key param) instead
of (list key param).
(url-handler): Adapt to new format.
* tests/database.scm ("db-get-builds"): Idem.
Diffstat (limited to 'src/cuirass/database.scm')
-rw-r--r-- | src/cuirass/database.scm | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm index 9b442c1..56f421d 100644 --- a/src/cuirass/database.scm +++ b/src/cuirass/database.scm @@ -58,7 +58,6 @@ read-sql-file read-quoted-string sqlite-exec - assqx-ref ;; Parameters. %package-database %package-schema-file @@ -461,16 +460,6 @@ log file for DRV." (#:repo-name . ,repo-name) (#:outputs . ,(db-get-outputs db id)))))) -;; XXX Change caller and remove -(define (assqx-ref filters key) - (match filters - (() - #f) - (((xkey xvalue) rest ...) - (if (eq? key xkey) - xvalue - (assqx-ref rest key))))) - (define (db-get-builds db filters) "Retrieve all builds in database DB which are matched by given FILTERS. FILTERS is an assoc list whose possible keys are 'id | 'jobset | 'job | @@ -547,13 +536,13 @@ Assumes that if group id stays the same the group headers stay the same." (collect-outputs x-builds-id x-repeated-row '() rows))))) (let* ((order (match (assq 'order filters) - (('order 'build-id) "id ASC") - (('order 'decreasing-build-id) "id DESC") - (('order 'finish-time) "stoptime DESC") - (('order 'finish-time+build-id) "stoptime DESC, id DESC") - (('order 'start-time) "starttime DESC") - (('order 'submission-time) "timestamp DESC") - (('order 'status+submission-time) + (('order . 'build-id) "id ASC") + (('order . 'decreasing-build-id) "id DESC") + (('order . 'finish-time) "stoptime DESC") + (('order . 'finish-time+build-id) "stoptime DESC, id DESC") + (('order . 'start-time) "starttime DESC") + (('order . 'submission-time) "timestamp DESC") + (('order . 'status+submission-time) ;; With this order, builds in 'running' state (-1) appear ;; before those in 'scheduled' state (-2). "status DESC, timestamp DESC") @@ -585,17 +574,17 @@ ORDER BY ~a, id ASC;" order)) (stmt (sqlite-prepare db stmt-text #:cache? #t))) (sqlite-bind-arguments stmt - #:id (assqx-ref filters 'id) - #:jobset (assqx-ref filters 'jobset) - #:job (assqx-ref filters 'job) - #:evaluation (assqx-ref filters 'evaluation) - #:system (assqx-ref filters 'system) - #:status (and=> (assqx-ref filters 'status) object->string) - #:borderlowid (assqx-ref filters 'border-low-id) - #:borderhighid (assqx-ref filters 'border-high-id) - #:borderlowtime (assqx-ref filters 'border-low-time) - #:borderhightime (assqx-ref filters 'border-high-time) - #:nr (match (assqx-ref filters 'nr) + #:id (assq-ref filters 'id) + #:jobset (assq-ref filters 'jobset) + #:job (assq-ref filters 'job) + #:evaluation (assq-ref filters 'evaluation) + #:system (assq-ref filters 'system) + #:status (and=> (assq-ref filters 'status) object->string) + #:borderlowid (assq-ref filters 'border-low-id) + #:borderhighid (assq-ref filters 'border-high-id) + #:borderlowtime (assq-ref filters 'border-low-time) + #:borderhightime (assq-ref filters 'border-high-time) + #:nr (match (assq-ref filters 'nr) (#f -1) (x x))) (sqlite-reset stmt) @@ -603,7 +592,7 @@ ORDER BY ~a, id ASC;" order)) (define (db-get-build db id) "Retrieve a build in database DB which corresponds to ID." - (match (db-get-builds db `((id ,id))) + (match (db-get-builds db `((id . ,id))) ((build) build) (() #f))) |