diff options
author | Christopher Baines <mail@cbaines.net> | 2019-06-02 16:20:51 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2019-06-02 21:48:02 +0100 |
commit | 4ccf3132b6f7e7946fc148228d4ff1ca93ab422c (patch) | |
tree | ca2f0847ba7736fa9287bd3332447d53d5cf3e85 /guix-data-service/jobs | |
parent | f03a750705980035f7efdfb4cc6498e4e0ce8054 (diff) | |
download | data-service-4ccf3132b6f7e7946fc148228d4ff1ca93ab422c.tar data-service-4ccf3132b6f7e7946fc148228d4ff1ca93ab422c.tar.gz |
Record job success without deleting the job record
Previously, the records for jobs would be deleted. It's useful to know when
jobs were inserted in to the database, as well as when they succeeded (if they
have). This change also makes it possible to keep track of jobs that have
failed, as they won't be deleted.
Diffstat (limited to 'guix-data-service/jobs')
-rw-r--r-- | guix-data-service/jobs/load-new-guix-revision.scm | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/guix-data-service/jobs/load-new-guix-revision.scm b/guix-data-service/jobs/load-new-guix-revision.scm index 58dc121..2ae372d 100644 --- a/guix-data-service/jobs/load-new-guix-revision.scm +++ b/guix-data-service/jobs/load-new-guix-revision.scm @@ -385,13 +385,15 @@ (simple-format #t "Successfully loaded ~A package/derivation pairs\n" - (length package-derivation-ids)))) + (length package-derivation-ids))) + #t) (lambda (key . args) (simple-format (current-error-port) "Failed extracting information: ~A ~A\n" key args) (force-output) - (exec-query conn "ROLLBACK"))))) + (exec-query conn "ROLLBACK") + #f)))) (define (load-new-guix-revision conn git-repository-id commit) (if (guix-revision-exists? conn git-repository-id commit) @@ -440,6 +442,14 @@ RETURNING id;") (list (number->string n))))) result)) +(define (record-job-succeeded conn id) + (exec-query + conn + (string-append + "UPDATE load_new_guix_revision_jobs WHERE id = $1 " + "SET succeeded_at = current_time") + (list id))) + (define (process-next-load-new-guix-revision-job conn) (let ((next (exec-query @@ -452,10 +462,7 @@ RETURNING id;") (begin (simple-format #t "Processing job ~A (commit: ~A, source: ~A)\n\n" id commit source) - (load-new-guix-revision conn git-repository-id commit) - (exec-query - conn - (string-append "DELETE FROM load_new_guix_revision_jobs WHERE id = '" - id - "'")))) + (when (eq? (load-new-guix-revision conn git-repository-id commit) + #t) + (record-job-succeeded conn id)))) (_ #f)))) |