aboutsummaryrefslogtreecommitdiff
path: root/guix-qa-frontpage/patchwork.scm
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-04-20 11:31:46 +0100
committerChristopher Baines <mail@cbaines.net>2023-04-20 11:31:46 +0100
commit866dcc5dedf5371d05ece7d1f387f1d27332f92a (patch)
tree5bccc54eb3d42b8852d1c3a5b622c78d05d3009d /guix-qa-frontpage/patchwork.scm
parent2fa4ef7c86ff45dafd5f92441776c10515c7d993 (diff)
downloadqa-frontpage-866dcc5dedf5371d05ece7d1f387f1d27332f92a.tar
qa-frontpage-866dcc5dedf5371d05ece7d1f387f1d27332f92a.tar.gz
Cap the number of patches read from patchwork
So this doesn't keep growning.
Diffstat (limited to 'guix-qa-frontpage/patchwork.scm')
-rw-r--r--guix-qa-frontpage/patchwork.scm30
1 files changed, 19 insertions, 11 deletions
diff --git a/guix-qa-frontpage/patchwork.scm b/guix-qa-frontpage/patchwork.scm
index ee43b5b..d69ea28 100644
--- a/guix-qa-frontpage/patchwork.scm
+++ b/guix-qa-frontpage/patchwork.scm
@@ -49,7 +49,8 @@
#:key patchwork
(archived? #f)
(order "-id")
- (states '("1" "2" "7" "11")))
+ (states '("1" "2" "7" "11"))
+ pages)
(define (set-uri-scheme uri scheme)
(string->uri
(simple-format
@@ -74,16 +75,23 @@
states)
"&"))))
- (define (make-request uri)
+ (define (make-request uri page-count)
(let-values (((response body)
- (http-request uri
- #:decode-body? #f)))
+ (retry-on-error
+ (lambda ()
+ (http-request uri
+ #:decode-body? #f))
+ #:times 2
+ #:delay 3)))
(append!
(vector->list
(json-string->scm (utf8->string body)))
(or
- (and=> (assq-ref (response-headers response)
- 'link)
+ (and=> (if (and pages
+ (> page-count pages))
+ #f
+ (assq-ref (response-headers response)
+ 'link))
(lambda (link-header)
(and=>
(find (lambda (link)
@@ -99,12 +107,11 @@
;; avoid the redirect, modify the URI
(set-uri-scheme
(assq-ref link-details 'uri)
- (uri-scheme uri))))))))
+ (uri-scheme uri))
+ (+ 1 page-count)))))))
'()))))
- (retry-on-error (lambda () (make-request initial-uri))
- #:times 10
- #:delay 5))
+ (make-request initial-uri 1))
(define* (latest-patchwork-series-by-issue
#:key patchwork)
@@ -147,7 +154,8 @@
issue-number
`(,@(vector-ref patch-series 0)
("patches" . (,patch))))))))
- (patchwork-patches #:patchwork patchwork))
+ (patchwork-patches #:patchwork patchwork
+ #:pages 10))
(let* ((data (hash-map->list cons result))
(mumi-data