diff options
author | Christopher Baines <mail@cbaines.net> | 2021-02-03 12:55:23 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2021-02-03 12:55:23 +0000 |
commit | 9a9d156366d8cf1348e2f29c0c760edc1ffb4c3d (patch) | |
tree | 1460d60c32970c96261be3f5ec9166e69374748a /guix-data-service | |
parent | 570c66722206951f55ab888aeaf0209b6d3bb822 (diff) | |
download | data-service-9a9d156366d8cf1348e2f29c0c760edc1ffb4c3d.tar data-service-9a9d156366d8cf1348e2f29c0c760edc1ffb4c3d.tar.gz |
Update most-recent-commits-for-branch to handle data availability
Diffstat (limited to 'guix-data-service')
-rw-r--r-- | guix-data-service/model/git-branch.scm | 48 | ||||
-rw-r--r-- | guix-data-service/web/repository/controller.scm | 4 |
2 files changed, 33 insertions, 19 deletions
diff --git a/guix-data-service/model/git-branch.scm b/guix-data-service/model/git-branch.scm index 91d5ec6..14ce48b 100644 --- a/guix-data-service/model/git-branch.scm +++ b/guix-data-service/model/git-branch.scm @@ -73,19 +73,30 @@ WHERE git_branches.commit = $1") before-date) (define query (string-append - "SELECT git_branches.commit, datetime, " - "(guix_revisions.id IS NOT NULL) as guix_revision_exists, " - "( - SELECT json_agg(event) - FROM load_new_guix_revision_job_events - INNER JOIN load_new_guix_revision_jobs ON - load_new_guix_revision_jobs.id = load_new_guix_revision_job_events.job_id - WHERE load_new_guix_revision_jobs.commit = git_branches.commit AND - git_branches.git_repository_id = load_new_guix_revision_jobs.git_repository_id - ) AS job_events " - "FROM git_branches " - "LEFT OUTER JOIN guix_revisions ON git_branches.commit = guix_revisions.commit " - "WHERE name = $1 AND git_branches.git_repository_id = $2" + " +SELECT git_branches.commit, + datetime, + ( + load_new_guix_revision_job_events.event IS NOT NULL + ) as data_available, + ( + SELECT json_agg(event) + FROM load_new_guix_revision_job_events + INNER JOIN load_new_guix_revision_jobs ON + load_new_guix_revision_jobs.id = load_new_guix_revision_job_events.job_id + WHERE load_new_guix_revision_jobs.commit = git_branches.commit AND + git_branches.git_repository_id = load_new_guix_revision_jobs.git_repository_id + ) AS job_events +FROM git_branches +LEFT OUTER JOIN guix_revisions + ON git_branches.commit = guix_revisions.commit +LEFT JOIN load_new_guix_revision_jobs + ON load_new_guix_revision_jobs.commit = guix_revisions.commit +LEFT JOIN load_new_guix_revision_job_events + ON job_id = load_new_guix_revision_jobs.id + AND load_new_guix_revision_job_events.event = 'success' +WHERE name = $1 + AND git_branches.git_repository_id = $2" (if after-date (simple-format #f " AND datetime > '~A'" (date->string after-date "~1 ~3")) @@ -94,17 +105,20 @@ WHERE git_branches.commit = $1") (simple-format #f " AND datetime < '~A'" (date->string before-date "~1 ~3")) "") - "ORDER BY datetime DESC" + " +ORDER BY datetime DESC" (if limit - (simple-format #f " LIMIT ~A;" limit) + (string-append + " +LIMIT " (number->string limit)) ""))) (map (match-lambda - ((commit datetime guix_revision_exists job_events) + ((commit datetime data_available job_events) (list commit datetime - (string=? guix_revision_exists "t") + (string=? data_available "t") (if (or (and (string? job_events) (string-null? job_events)) (eq? #f job_events)) '() diff --git a/guix-data-service/web/repository/controller.scm b/guix-data-service/web/repository/controller.scm index ee543c4..dcc0992 100644 --- a/guix-data-service/web/repository/controller.scm +++ b/guix-data-service/web/repository/controller.scm @@ -139,10 +139,10 @@ `((revisions . ,(list->vector (map (match-lambda - ((commit-hash date revision-exists? _) + ((commit-hash date data-available? _) `((date . ,date) (commit-hash . ,commit-hash) - (data_available . ,revision-exists?)))) + (data_available . ,data-available?)))) revisions)))))) (else (render-html |