From 325c79d91fb39bbe4e153e22131239fb1123c735 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 8 May 2022 01:38:56 +0200 Subject: run: Loop over all pages of issues For each page of issues, watch those issues. Watcher code needs to be implemented. --- src/main.lisp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main.lisp b/src/main.lisp index ecf0ed3..0706a33 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -22,10 +22,22 @@ (login config) (token config))))) - (fetch-issues - (endpoint config) - (jql config) - :basic-auth-token basic-auth-token))) + (loop + (let* ((response (fetch-issues + (endpoint config) + (jql config) + :basic-auth-token basic-auth-token)) + + (start-at (gethash "startAt" response)) + (max-results (gethash "maxResults" response)) + (total (gethash "total" response))) + + (watch-issues (gethash "issues" response)) + + ;; Stop looping if we're on the last page of results. + (when (> start-at + (- total max-results)) + (return)))))) (defun fetch-issues (endpoint jql &key basic-auth-token) (jzon:parse @@ -37,3 +49,7 @@ :headers `((:content-type . "application/json") (:authorization . ,(format nil "Basic ~A" basic-auth-token)))))) + +(defun watch-issues (issues) + (loop for issue across issues do + (format t "Watching issue ~A~%" (gethash "key" issue)))) -- cgit v1.2.3