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
1 changed files with 18 additions and 21 deletions
|
|
@ -133,24 +133,17 @@ WHERE NOT EXISTS (
|
||||||
(list (number->string build-id)
|
(list (number->string build-id)
|
||||||
build-server-id)))
|
build-server-id)))
|
||||||
|
|
||||||
(define (insert-blocked-builds conn data)
|
(define (insert-blocked-builds conn build-server-id data)
|
||||||
(define (create-partitions)
|
(define (create-partition)
|
||||||
(for-each
|
|
||||||
(lambda (build-server-id)
|
|
||||||
(exec-query
|
(exec-query
|
||||||
conn
|
conn
|
||||||
(string-append
|
(string-append
|
||||||
"
|
"
|
||||||
CREATE TABLE IF NOT EXISTS blocked_builds_build_server__"
|
CREATE TABLE IF NOT EXISTS blocked_builds_build_server_"
|
||||||
(number->string build-server-id) "
|
(number->string build-server-id) "
|
||||||
PARTITION OF blocked_builds FOR VALUES IN ("
|
PARTITION OF blocked_builds FOR VALUES IN ("
|
||||||
(number->string build-server-id)
|
(number->string build-server-id)
|
||||||
")")))
|
")")))
|
||||||
(delete-duplicates
|
|
||||||
(map (lambda (fields)
|
|
||||||
(string->number (car fields)))
|
|
||||||
data)
|
|
||||||
=)))
|
|
||||||
|
|
||||||
(define (try-insert)
|
(define (try-insert)
|
||||||
(exec-query
|
(exec-query
|
||||||
|
|
@ -165,8 +158,11 @@ INSERT INTO blocked_builds (
|
||||||
VALUES "
|
VALUES "
|
||||||
(string-join
|
(string-join
|
||||||
(map (match-lambda
|
(map (match-lambda
|
||||||
((a b c)
|
((b c)
|
||||||
(simple-format #f "(~A, ~A, ~A)" a b c)))
|
(simple-format #f "(~A, ~A, ~A)"
|
||||||
|
build-server-id
|
||||||
|
b
|
||||||
|
c)))
|
||||||
data)
|
data)
|
||||||
", ")
|
", ")
|
||||||
"
|
"
|
||||||
|
|
@ -197,6 +193,7 @@ WHERE id = $1")
|
||||||
(unless (null? blocking-derivation-output-details-set-ids)
|
(unless (null? blocking-derivation-output-details-set-ids)
|
||||||
(insert-blocked-builds
|
(insert-blocked-builds
|
||||||
conn
|
conn
|
||||||
|
build-server-id
|
||||||
(map
|
(map
|
||||||
(lambda (blocking-derivation-output-details-set-id)
|
(lambda (blocking-derivation-output-details-set-id)
|
||||||
(list build-server-id
|
(list build-server-id
|
||||||
|
|
@ -242,10 +239,10 @@ WHERE builds.id IN ("
|
||||||
blocking-derivation-output-details-set-id)))
|
blocking-derivation-output-details-set-id)))
|
||||||
(insert-blocked-builds
|
(insert-blocked-builds
|
||||||
conn
|
conn
|
||||||
|
build-server-id
|
||||||
(map
|
(map
|
||||||
(lambda (blocked-derivation-output-details-set-id)
|
(lambda (blocked-derivation-output-details-set-id)
|
||||||
(list build-server-id
|
(list blocked-derivation-output-details-set-id
|
||||||
blocked-derivation-output-details-set-id
|
|
||||||
blocking-derivation-output-details-set-id))
|
blocking-derivation-output-details-set-id))
|
||||||
blocked-derivation-output-details-set-ids)))))
|
blocked-derivation-output-details-set-ids)))))
|
||||||
(exec-query
|
(exec-query
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue