diff options
author | Christopher Baines <mail@cbaines.net> | 2019-06-24 20:30:47 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2019-06-24 20:30:47 +0100 |
commit | 54b992246637fb4f73a9d8b15d381cdc7bce3183 (patch) | |
tree | 8e2f8a01bcdf416ee59cb5c09af8a123d93e8146 /guix-data-service/jobs | |
parent | afa86d61158f3bbded19f71bed9370d76a4f6622 (diff) | |
download | data-service-54b992246637fb4f73a9d8b15d381cdc7bce3183.tar data-service-54b992246637fb4f73a9d8b15d381cdc7bce3183.tar.gz |
Iterate the log viewing
Replace the Guile-side HTML escaping with a less complete, but hopefully
faster PostgreSQL side HTML escaping approach.
Also, allow reading part of the log, by default, the last 1,000,000
characters, as this should render quickly.
Diffstat (limited to 'guix-data-service/jobs')
-rw-r--r-- | guix-data-service/jobs/load-new-guix-revision.scm | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/guix-data-service/jobs/load-new-guix-revision.scm b/guix-data-service/jobs/load-new-guix-revision.scm index 8650202..7eb6cdf 100644 --- a/guix-data-service/jobs/load-new-guix-revision.scm +++ b/guix-data-service/jobs/load-new-guix-revision.scm @@ -69,14 +69,41 @@ #f) ; number of characters that can be read "w")) -(define (log-for-job conn job-id) +(define* (log-for-job conn job-id + #:key + character-limit + start-character) + (define (sql-html-escape s) + (string-append + "replace(" + (string-append + "replace(" + (string-append + "replace(" + s + ",'&','&')") + ",'<','<')") + ",'>','>')")) + + (define (get-characters s) + (if start-character + (simple-format #f "substr(~A, ~A, ~A)" + s start-character + character-limit) + (simple-format #f "right(~A, ~A)" s character-limit))) + (define log-query - "SELECT contents FROM load_new_guix_revision_job_logs WHERE job_id = $1") + (string-append + "SELECT " + (sql-html-escape (get-characters "contents")) + " FROM load_new_guix_revision_job_logs WHERE job_id = $1")) (define parts-query (string-append - "SELECT STRING_AGG(contents, '' ORDER BY id ASC) " - "FROM load_new_guix_revision_job_log_parts WHERE job_id = $1")) + "SELECT " + (sql-html-escape + (get-characters "STRING_AGG(contents, '' ORDER BY id ASC)")) + " FROM load_new_guix_revision_job_log_parts WHERE job_id = $1")) (match (exec-query conn log-query (list job-id)) (((contents)) |