mirror of
git://git.savannah.gnu.org/guix/data-service.git
synced 2023-12-14 03:23:03 +01:00
Rework insert-blocked-builds to make it more efficient
This also fixes a typo in the partition name.
This commit is contained in:
parent
4101c6b897
commit
0f22e3ab40
|
@ -133,24 +133,17 @@ WHERE NOT EXISTS (
|
|||
(list (number->string build-id)
|
||||
build-server-id)))
|
||||
|
||||
(define (insert-blocked-builds conn data)
|
||||
(define (create-partitions)
|
||||
(for-each
|
||||
(lambda (build-server-id)
|
||||
(exec-query
|
||||
conn
|
||||
(string-append
|
||||
"
|
||||
CREATE TABLE IF NOT EXISTS blocked_builds_build_server__"
|
||||
(number->string build-server-id) "
|
||||
(define (insert-blocked-builds conn build-server-id data)
|
||||
(define (create-partition)
|
||||
(exec-query
|
||||
conn
|
||||
(string-append
|
||||
"
|
||||
CREATE TABLE IF NOT EXISTS blocked_builds_build_server_"
|
||||
(number->string build-server-id) "
|
||||
PARTITION OF blocked_builds FOR VALUES IN ("
|
||||
(number->string build-server-id)
|
||||
")")))
|
||||
(delete-duplicates
|
||||
(map (lambda (fields)
|
||||
(string->number (car fields)))
|
||||
data)
|
||||
=)))
|
||||
(number->string build-server-id)
|
||||
")")))
|
||||
|
||||
(define (try-insert)
|
||||
(exec-query
|
||||
|
@ -165,8 +158,11 @@ INSERT INTO blocked_builds (
|
|||
VALUES "
|
||||
(string-join
|
||||
(map (match-lambda
|
||||
((a b c)
|
||||
(simple-format #f "(~A, ~A, ~A)" a b c)))
|
||||
((b c)
|
||||
(simple-format #f "(~A, ~A, ~A)"
|
||||
build-server-id
|
||||
b
|
||||
c)))
|
||||
data)
|
||||
", ")
|
||||
"
|
||||
|
@ -197,6 +193,7 @@ WHERE id = $1")
|
|||
(unless (null? blocking-derivation-output-details-set-ids)
|
||||
(insert-blocked-builds
|
||||
conn
|
||||
build-server-id
|
||||
(map
|
||||
(lambda (blocking-derivation-output-details-set-id)
|
||||
(list build-server-id
|
||||
|
@ -242,10 +239,10 @@ WHERE builds.id IN ("
|
|||
blocking-derivation-output-details-set-id)))
|
||||
(insert-blocked-builds
|
||||
conn
|
||||
build-server-id
|
||||
(map
|
||||
(lambda (blocked-derivation-output-details-set-id)
|
||||
(list build-server-id
|
||||
blocked-derivation-output-details-set-id
|
||||
(list blocked-derivation-output-details-set-id
|
||||
blocking-derivation-output-details-set-id))
|
||||
blocked-derivation-output-details-set-ids)))))
|
||||
(exec-query
|
||||
|
|
Loading…
Reference in a new issue