1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
;;; Guix QA Frontpage
;;;
;;; Copyright © 2022 Christopher Baines <mail@cbaines.net>
;;;
;;; This program is free software: you can redistribute it and/or
;;; modify it under the terms of the GNU Affero General Public License
;;; as published by the Free Software Foundation, either version 3 of
;;; the License, or (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;;; Affero General Public License for more details.
;;;
;;; You should have received a copy of the GNU Affero General Public
;;; License along with this program. If not, see
;;; <http://www.gnu.org/licenses/>.
(define-module (guix-qa-frontpage mumi)
#:use-module (srfi srfi-1)
#:use-module (ice-9 match)
#:use-module (kolam http)
#:use-module ((guix-data-service utils) #:select (chunk-for-each!))
#:use-module ((guix-build-coordinator utils)
#:select (retry-on-error))
#:export (mumi-search-issues
mumi-issue-blocking-info
mumi-issue-open?
mumi-bulk-issues))
(define (mumi-search-issues query)
(with-exception-handler
(lambda (exn)
(simple-format
(current-error-port)
"exception when searching issues: ~A\n"
exn)
#f)
(lambda ()
(let ((response
(graphql-http-get "https://issues.guix.gnu.org/graphql"
`(document (query (#(issues #:search ,query) number title date))))))
(assoc-ref response
"issues")))
#:unwind? #t))
(define (mumi-issue-blocking-info number)
(let ((response
(graphql-http-get "https://issues.guix.gnu.org/graphql"
`(document (query (#(issue #:number ,number) blockedby blocks))))))
(cdr (first response))))
(define (mumi-issue-open? number)
(let ((response
(graphql-http-get "https://issues.guix.gnu.org/graphql"
`(document (query (#(issue #:number ,number) open))))))
(assoc-ref (cdr (first response))
"open")))
(define (mumi-bulk-issues numbers)
(let ((number-to-data
(make-hash-table)))
(chunk-for-each!
(lambda (chunk)
(let ((response
(retry-on-error
(lambda ()
(graphql-http-get
"https://issues.guix.gnu.org/graphql"
`(document
,@(map (lambda (number)
`(query (#(issue #:number ,number)
number title open severity tags)))
chunk))))
#:times 3
#:delay 0)))
(for-each
(lambda (res)
(let ((data (cdr res)))
(hash-set! number-to-data
(assoc-ref data "number")
`((title . ,(assoc-ref data "title"))
(open? . ,(assoc-ref data "open"))
(tags . ,(vector->list
(assoc-ref data "tags")))
(severity . ,(assoc-ref data "severity"))))))
response)))
30
(list-copy numbers))
(map (lambda (number)
(hash-ref number-to-data number))
numbers)))
|