aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-12-27 10:27:21 +0000
committerChristopher Baines <mail@cbaines.net>2020-12-27 10:27:21 +0000
commitcbe9859064dba04d592bdc810cf61b3e87b63b28 (patch)
treef3f95e8eeb8c8f40f26bc8ba0807dc33b606941d /guix-data-service
parent8d6f255646bf09aaea4909cf000d425037e2223d (diff)
downloaddata-service-cbe9859064dba04d592bdc810cf61b3e87b63b28.tar
data-service-cbe9859064dba04d592bdc810cf61b3e87b63b28.tar.gz
Support inserting build statuses without a transaction
In case this code is run as part of a bigger transaction.
Diffstat (limited to 'guix-data-service')
-rw-r--r--guix-data-service/model/build-status.scm18
1 files changed, 11 insertions, 7 deletions
diff --git a/guix-data-service/model/build-status.scm b/guix-data-service/model/build-status.scm
index ec833b5..4a2a801 100644
--- a/guix-data-service/model/build-status.scm
+++ b/guix-data-service/model/build-status.scm
@@ -58,7 +58,8 @@ WHERE builds.build_server_id = $1 AND
(list build-id)
`((,timestamp ,status))))
-(define (insert-build-statuses conn build-ids data)
+(define* (insert-build-statuses conn build-ids data
+ #:key (transaction? #t))
(define query
(string-append
"
@@ -130,10 +131,13 @@ WINDOW rows_for_build AS (
(exec-query conn query))
- (with-postgresql-transaction
- conn
- (lambda (conn)
- (exec-query conn query '())
+ (define (operations conn)
+ (exec-query conn query '())
+
+ (delete-old-latest-status-entries conn)
+ (insert-new-latest-status-entries conn))
- (delete-old-latest-status-entries conn)
- (insert-new-latest-status-entries conn))))
+ (if transaction?
+ (with-postgresql-transaction conn
+ operations)
+ (operations conn)))