Reformat queries in the load-new-guix-revision module
This commit is contained in:
parent
39f52e3a2e
commit
02b75d857a
1 changed files with 29 additions and 22 deletions
|
|
@ -90,8 +90,9 @@
|
||||||
(exec-query
|
(exec-query
|
||||||
conn
|
conn
|
||||||
(string-append
|
(string-append
|
||||||
"INSERT INTO load_new_guix_revision_job_log_parts (id, job_id, contents) "
|
"
|
||||||
"VALUES (nextval('" (log-part-sequence-name job_id) "'), $1, $2)")
|
INSERT INTO load_new_guix_revision_job_log_parts (id, job_id, contents)
|
||||||
|
VALUES (nextval('" (log-part-sequence-name job_id) "'), $1, $2)")
|
||||||
(list job_id s)))
|
(list job_id s)))
|
||||||
|
|
||||||
(define (log-string s)
|
(define (log-string s)
|
||||||
|
|
@ -283,13 +284,14 @@ WHERE job_id = $1"
|
||||||
(exec-query
|
(exec-query
|
||||||
conn
|
conn
|
||||||
(string-append
|
(string-append
|
||||||
"UPDATE load_new_guix_revision_job_logs SET contents = "
|
"
|
||||||
"("
|
UPDATE load_new_guix_revision_job_logs SET contents = (
|
||||||
"SELECT STRING_AGG(contents, '' ORDER BY id ASC) FROM "
|
SELECT STRING_AGG(contents, '' ORDER BY id ASC)
|
||||||
"load_new_guix_revision_job_log_parts WHERE job_id = $1 "
|
FROM load_new_guix_revision_job_log_parts
|
||||||
"GROUP BY job_id"
|
WHERE job_id = $1
|
||||||
")"
|
GROUP BY job_id
|
||||||
"WHERE job_id = $1")
|
)
|
||||||
|
WHERE job_id = $1")
|
||||||
(list job-id))
|
(list job-id))
|
||||||
(exec-query
|
(exec-query
|
||||||
conn
|
conn
|
||||||
|
|
@ -1650,37 +1652,42 @@ SELECT EXISTS(
|
||||||
(let ((result
|
(let ((result
|
||||||
(exec-query
|
(exec-query
|
||||||
conn
|
conn
|
||||||
(string-append
|
"
|
||||||
"SELECT id, commit, source, git_repository_id "
|
SELECT id, commit, source, git_repository_id
|
||||||
"FROM load_new_guix_revision_jobs ORDER BY id ASC LIMIT $1")
|
FROM load_new_guix_revision_jobs
|
||||||
|
ORDER BY id ASC
|
||||||
|
LIMIT $1"
|
||||||
(list (number->string n)))))
|
(list (number->string n)))))
|
||||||
result))
|
result))
|
||||||
|
|
||||||
(define (select-job-for-update conn id)
|
(define (select-job-for-update conn id)
|
||||||
(exec-query
|
(exec-query
|
||||||
conn
|
conn
|
||||||
(string-append
|
"
|
||||||
"SELECT id, commit, source, git_repository_id "
|
SELECT id, commit, source, git_repository_id
|
||||||
"FROM load_new_guix_revision_jobs "
|
FROM load_new_guix_revision_jobs
|
||||||
"WHERE id = $1 AND succeeded_at IS NULL "
|
WHERE id = $1
|
||||||
"FOR NO KEY UPDATE SKIP LOCKED")
|
AND succeeded_at IS NULL
|
||||||
|
FOR NO KEY UPDATE SKIP LOCKED"
|
||||||
(list id)))
|
(list id)))
|
||||||
|
|
||||||
(define (record-job-event conn job-id event)
|
(define (record-job-event conn job-id event)
|
||||||
(exec-query
|
(exec-query
|
||||||
conn
|
conn
|
||||||
(string-append
|
(string-append
|
||||||
"INSERT INTO load_new_guix_revision_job_events (job_id, event) "
|
"
|
||||||
"VALUES ($1, $2)")
|
INSERT INTO load_new_guix_revision_job_events (job_id, event)
|
||||||
|
VALUES ($1, $2)")
|
||||||
(list job-id event)))
|
(list job-id event)))
|
||||||
|
|
||||||
(define (record-job-succeeded conn id)
|
(define (record-job-succeeded conn id)
|
||||||
(exec-query
|
(exec-query
|
||||||
conn
|
conn
|
||||||
(string-append
|
(string-append
|
||||||
"UPDATE load_new_guix_revision_jobs "
|
"
|
||||||
"SET succeeded_at = clock_timestamp() "
|
UPDATE load_new_guix_revision_jobs
|
||||||
"WHERE id = $1 ")
|
SET succeeded_at = clock_timestamp()
|
||||||
|
WHERE id = $1 ")
|
||||||
(list id)))
|
(list id)))
|
||||||
|
|
||||||
(define (fetch-unlocked-jobs conn)
|
(define (fetch-unlocked-jobs conn)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue