Enhance ensure-build-exists
Support calling it with derivation-output-details-set-id, which can be used when querying for builds.
This commit is contained in:
parent
5758795777
commit
c355c42584
1 changed files with 24 additions and 10 deletions
|
|
@ -374,7 +374,8 @@ UPDATE builds SET derivation_output_details_set_id = (
|
||||||
|
|
||||||
build-ids))
|
build-ids))
|
||||||
|
|
||||||
(define (insert-build conn build-server-id derivation-file-name)
|
(define* (insert-build conn build-server-id derivation-file-name
|
||||||
|
#:key derivation-output-details-set-id)
|
||||||
(match (exec-query
|
(match (exec-query
|
||||||
conn
|
conn
|
||||||
(string-append
|
(string-append
|
||||||
|
|
@ -388,9 +389,11 @@ VALUES ("
|
||||||
", "
|
", "
|
||||||
(or
|
(or
|
||||||
(and=>
|
(and=>
|
||||||
|
(or
|
||||||
|
derivation-output-details-set-id
|
||||||
(select-derivations-by-output-details-set-id-by-derivation-file-name
|
(select-derivations-by-output-details-set-id-by-derivation-file-name
|
||||||
conn
|
conn
|
||||||
derivation-file-name)
|
derivation-file-name))
|
||||||
number->string)
|
number->string)
|
||||||
"NULL")
|
"NULL")
|
||||||
")
|
")
|
||||||
|
|
@ -398,16 +401,27 @@ RETURNING (id)"))
|
||||||
(((id))
|
(((id))
|
||||||
(string->number id))))
|
(string->number id))))
|
||||||
|
|
||||||
(define (ensure-build-exists conn
|
(define* (ensure-build-exists conn
|
||||||
build-server-id
|
build-server-id
|
||||||
derivation-file-name)
|
derivation-file-name
|
||||||
|
#:key derivation-output-details-set-id)
|
||||||
(let ((existing-build-id
|
(let ((existing-build-id
|
||||||
(select-build-id-by-build-server-and-derivation-file-name
|
(select-build-id-by-build-server-and-derivation-file-name
|
||||||
conn build-server-id derivation-file-name)))
|
conn build-server-id derivation-file-name)))
|
||||||
|
|
||||||
(if existing-build-id
|
(if existing-build-id
|
||||||
existing-build-id
|
(begin
|
||||||
|
(exec-query
|
||||||
|
conn
|
||||||
|
"
|
||||||
|
UPDATE builds SET derivation_output_details_set_id = $2
|
||||||
|
WHERE builds.id = $1 AND derivation_output_details_set_id IS NULL"
|
||||||
|
(list (number->string existing-build-id)
|
||||||
|
(number->string derivation-output-details-set-id)))
|
||||||
|
|
||||||
|
existing-build-id)
|
||||||
(insert-build conn
|
(insert-build conn
|
||||||
build-server-id
|
build-server-id
|
||||||
derivation-file-name))))
|
derivation-file-name
|
||||||
|
#:derivation-output-details-set-id
|
||||||
|
derivation-output-details-set-id))))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue