diff options
author | Christopher Baines <mail@cbaines.net> | 2023-06-15 11:15:58 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2023-06-15 11:15:58 +0100 |
commit | f8c2008da7107ef1f5e9b1d1f06391d84cdc9a7c (patch) | |
tree | 02a49842e627caab9701401e082c656c2fb02bc4 /guix-qa-frontpage/server.scm | |
parent | 74840c7c3d66f5f36288e8fd602891c7da60ee02 (diff) | |
download | qa-frontpage-f8c2008da7107ef1f5e9b1d1f06391d84cdc9a7c.tar qa-frontpage-f8c2008da7107ef1f5e9b1d1f06391d84cdc9a7c.tar.gz |
Move issue related code from the server module
Diffstat (limited to 'guix-qa-frontpage/server.scm')
-rw-r--r-- | guix-qa-frontpage/server.scm | 163 |
1 files changed, 1 insertions, 162 deletions
diff --git a/guix-qa-frontpage/server.scm b/guix-qa-frontpage/server.scm index 9678c1f..82b8a43 100644 --- a/guix-qa-frontpage/server.scm +++ b/guix-qa-frontpage/server.scm @@ -50,9 +50,7 @@ #:use-module (guix-qa-frontpage view branches) #:use-module (guix-qa-frontpage view branch) #:use-module (guix-qa-frontpage view issue) - #:export (start-guix-qa-frontpage-web-server - - start-refresh-patch-branches-data-thread)) + #:export (start-guix-qa-frontpage-web-server)) (define (branch-for-issue database issue-number) (let ((branches @@ -472,162 +470,3 @@ error: guix-data-service could not start, as it could not bind to port ~A Check if it's already running, or whether another process is using that port. Also, the port used can be changed by passing the --port option.\n" port))))))) - -(define (issue-data number) - (let* ((base-and-target-refs - (get-issue-branch-base-and-target-refs - number)) - (derivation-changes-data - change-details - (if base-and-target-refs - (with-exception-handler - (lambda (exn) - (simple-format - (current-error-port) - "exception fetching derivation changes: ~A\n" - exn) - - (values #f #f)) - (lambda () - (revision-derivation-changes - (revision-derivation-changes-url - base-and-target-refs - #:systems %systems-to-submit-builds-for))) - #:unwind? #t) - (values #f #f))) - (derivation-changes-counts - (if derivation-changes-data - (derivation-changes-counts - derivation-changes-data - %systems-to-submit-builds-for) - #f)) - (builds-missing? - (if derivation-changes-data - (builds-missing-for-derivation-changes? - derivation-changes-data) - #t)) - (comparison-details - (and - base-and-target-refs - (with-exception-handler - (lambda (exn) - (if (guix-data-service-error? exn) - ;; TODO Return some description this error that can be - ;; cached - #f - (raise-exception exn))) - (lambda () - (revision-comparison - (revision-comparison-url - base-and-target-refs))) - #:unwind? #t)))) - - (values - base-and-target-refs - derivation-changes-counts - change-details - builds-missing? - comparison-details))) - -(define* (start-refresh-patch-branches-data-thread - database - #:key - (number-of-series-to-refresh 250)) - (define frequency - (* 15 60)) - - (define (refresh-data) - (simple-format (current-error-port) - "refreshing patch branches data...\n") - (let* ((latest-series - (with-sqlite-cache - database - 'latest-patchwork-series-by-issue - latest-patchwork-series-by-issue - #:ttl (/ frequency 2))) - (series-to-refresh - (if (> (length latest-series) - number-of-series-to-refresh) - (take latest-series number-of-series-to-refresh) - latest-series))) - - (update-repository!) - - (n-par-for-each - 5 - (lambda (series) - (with-exception-handler - (lambda (exn) - (unless - (and (guix-data-service-error? exn) - ;; This probably just means the target - ;; revision hasn't been processed yet. The - ;; Guix Data Service should send a more - ;; informative response though. - (and=> (assoc-ref - (guix-data-service-error-response-body exn) - "error") - (lambda (error) - (string=? error - "invalid query")))) - (simple-format - (current-error-port) - "failed fetching derivation changes for issue ~A: ~A\n" - (car series) - exn)) - - #f) - (lambda () - (let ((base-and-target-refs - derivation-changes-counts - change-details - builds-missing? - comparison-details - (with-sqlite-cache - database - 'issue-data - issue-data - #:args - (list (car series)) - #:ttl (/ frequency 2)))) - - (with-sqlite-cache - database - 'issue-patches-overall-status - (lambda (id) - (issue-patches-overall-status - derivation-changes-counts - builds-missing? - (assq-ref (assq-ref series 'mumi) - 'tags))) - #:args (list (car series)) - #:ttl 0))) - #:unwind? #t)) - series-to-refresh))) - - (call-with-new-thread - (lambda () - (while #t - (let ((start-time (current-time))) - (with-exception-handler - (lambda (exn) - (simple-format - (current-error-port) - "exception in data refresh thread: ~A\n" - exn)) - (lambda () - (with-time-logging "refreshing data" - (with-throw-handler #t - refresh-data - (lambda args - (display (backtrace) (current-error-port)) - (newline (current-error-port)))))) - #:unwind? #t) - - (let ((time-taken - (- (current-time) start-time))) - (if (>= time-taken frequency) - (simple-format (current-error-port) - "warning: refreshing data is behind\n") - (sleep - (- frequency time-taken))))))))) |