git.fiddlerwoaroof.com
Browse code

misc: changes

Ed Langley authored on 31/07/2019 18:40:57
Showing 2 changed files
... ...
@@ -1,12 +1,11 @@
1
-(in-package #:jira-api) 
1
+(in-package #:jira-api)
2 2
 
3
-; curl -u user:password https://atomampd.atlassian.net/rest/api/2/issue/ATOMOS-212 | jq .
4 3
 (defparameter *hostname* "https://atomampd.atlassian.net")
5 4
 (defparameter *endpoint* (princ-to-string (puri:merge-uris *hostname* "/rest/api/2/")))
6 5
 (defparameter *agile-endpoint* (princ-to-string (puri:merge-uris *hostname* "/rest/agile/1.0/")))
7 6
 
8
-(defun update-hostname ()
9
-  (setf *hostname* "https://jira.cnvrmedia.net")
7
+(defun update-hostname (base)
8
+  (setf *hostname* (format nil "https://~a" base))
10 9
   (setf *endpoint* (princ-to-string (puri:merge-uris "/rest/api/2/" *hostname*)))
11 10
   (setf *agile-endpoint* (princ-to-string (puri:merge-uris *hostname* "/rest/agile/1.0/"))))
12 11
 
... ...
@@ -59,5 +58,3 @@
59 58
                          :content post-data
60 59
                          :basic-authorization auth
61 60
                          :want-stream t)))
62
-
63
-
... ...
@@ -1,11 +1,15 @@
1
-#!/usr/bin/sbcl --script
1
+#!/usr/bin/env sbcl --script
2 2
 (require :sb-posix)
3 3
 (load #p"~/quicklisp/setup.lisp")
4
+
4 5
 (eval-when (:load-toplevel :compile-toplevel :execute)
5 6
   (push (truename ".") asdf:*central-registry*)
6 7
   (ql:quickload :ubiquitous)
7 8
   (sb-posix:setenv "CC" "gcc" 1)
8
-  (ql:quickload :net.didierverna.clon)
9
+  (ql:quickload :net.didierverna.clon))
10
+
11
+(eval-when (:load-toplevel :compile-toplevel :execute)
12
+  (push (truename ".") asdf:*central-registry*)
9 13
   (ql:quickload :jira-api))
10 14
 
11 15
 (defpackage #:jira-api.client
... ...
@@ -14,13 +18,13 @@
14 18
 (in-package #:jira-api.client)
15 19
 (defparameter *version* (format nil "0.1-init"))
16 20
 
17
-(defparameter *endpoint-template* "https://~a.atlassian.net/rest/api/2/")
21
+(defparameter *endpoint-template* "https://~a/rest/api/2/")
18 22
 
19 23
 (eval-when (:compile-toplevel :load-toplevel :execute)
20 24
   (ubiquitous:restore :jira-api))
21 25
 
22 26
 (defsynopsis (:postfix "ARGUMENTS...")
23
-  (text :contents "A command line client for Jira issues")
27
+    (text :contents "A command line client for Jira issues")
24 28
   (group (:header "Main actions")
25 29
          (flag :short-name "lp" :long-name "list-projects"
26 30
                :description "List available JIRA projects")
... ...
@@ -30,17 +34,16 @@
30 34
          (flag :short-name "i"
31 35
                :long-name "get-issue"
32 36
                :description "show an issue")
33
-         ;(flag :short-name "pi" :long-name "post-issue"
34
-         ;      :description "post and issue")
37
+         ;;(flag :short-name "pi" :long-name "post-issue"
38
+         ;;      :description "post and issue")
35 39
          )
36 40
   (group (:header "JIRA options")
37 41
          (stropt :long-name "jira-account"
38 42
                  :description "The jira account to use."
39
-                 :argument-name "URL-SUBDOMAIN"
40
-                 :default-value (ubiquitous:value :jira :account)))
43
+                 :argument-name "URL-SUBDOMAIN"))
41 44
   (group (:header "Filtering Issues")
42 45
          (flag :short-name "c" :long-name "with-comments"
43
-               :description "Show the issue's comments") 
46
+               :description "Show the issue's comments")
44 47
          (stropt :short-name "s" :long-name "status"
45 48
                  :description "Only show issues with a certain status"))
46 49
   (group (:header "Other options")
... ...
@@ -58,48 +61,84 @@
58 61
 (defun dump-configuration ()
59 62
   (format t "~&~s~&"
60 63
           (hash-table-alist
61
-            (ubiquitous:value :jira))))
64
+           (ubiquitous:value :jira))))
65
+
66
+(defun get-track-eng-issues (auth)
67
+  (let ((jql
68
+          (concatenate 'string
69
+                       "project = CJPM AND status"
70
+                       "  in (Open, \"In Progress\", Resolved, Closed, \"Needs QR\","
71
+                       "      \"Needs Demo\", \"Needs SOX\", \"Dev Done\")"
72
+                       " AND component = EMPTY"
73
+                       " AND \"Product Domain\" = Insights"
74
+                       " ORDER BY Rank ASC")))
75
+    (jira-api:get-issues auth :jql jql)))
76
+
77
+(defun get-needsqr-issues (auth)
78
+  (let ((jql
79
+          (concatenate 'string
80
+                       "project = CJPM"
81
+                       " AND status in (\"Needs QR\")"
82
+                       " AND \"Product Domain\" = Insights"
83
+                       " ORDER BY Rank ASC")))
84
+    (jira-api:get-issues auth :jql jql)))
85
+
86
+(defun get-insights-issues (auth)
87
+  (let ((jql
88
+          (concatenate 'string
89
+                       "project = CJPM"
90
+                       " AND status in (Open, \"In Progress\", Resolved, \"Needs QR\","
91
+                       "                \"Needs Demo\", \"Needs SOX\", \"Dev Done\")"
92
+                       " AND \"Product Domain\" = Insights"
93
+                       " ORDER BY Rank ASC")))
94
+    (jira-api:get-issues auth :jql jql)))
62 95
 
63 96
 (defun main ()
64 97
   (ubiquitous:restore :jira-api)
65 98
   (setf *auth* (ubiquitous:value :jira :creds))
66 99
   (make-context)
67 100
 
68
-  (jira-api::update-hostname (getopt :long-name "jira-account"))
69
-  (cond
70
-    ((getopt :long-name "help") (help))
71
-    ((getopt :long-name "version") (format t "~&~a~%" *version*))
72
-    ((getopt :long-name "dump-configuration") (dump-configuration))
73
-    ((getopt :long-name "configure") (let ((creds (prompt :creds))
74
-                                           (account (prompt :jira-account)))
75
-                                       (setf (ubiquitous:value :jira :creds) creds)
76
-                                       (setf (ubiquitous:value :jira :account) account)
77
-                                       (dump-configuration)))
78
-    ((getopt :long-name "get-issue") (let ((options (remainder)))
79
-                                       (format t "~&~a~&"
80
-                                               (jira-api::show
81
-                                                 (jira-api::json2sheeple
101
+  (let ((configure (getopt :long-name "configure"))
102
+        (help (getopt :long-name "help")))
103
+    (unless (or configure help)
104
+      (jira-api::update-hostname (ubiquitous:value :jira :account)))
105
+    (cond
106
+      (help (help))
107
+      ((getopt :long-name "version") (format t "~&~a~%" *version*))
108
+      ((getopt :long-name "dump-configuration") (dump-configuration))
109
+      (configure (let ((creds (prompt :creds))
110
+                       (account (prompt :jira-account)))
111
+                   (setf (ubiquitous:value :jira :creds) creds)
112
+                   (setf (ubiquitous:value :jira :account) account)
113
+                   (dump-configuration)))
114
+      ((getopt :long-name "get-issue") (let ((options (remainder)))
115
+                                         (format t "~&~a~&"
116
+                                                 (jira-api::show
117
+                                                  (jira-api::json2sheeple
82 118
                                                    (jira-api::get-issue *auth*
83 119
                                                                         (format nil "~a-~a"
84 120
                                                                                 (car options)
85 121
                                                                                 (cadr options)))
86 122
                                                    jira-api::=issue=)
87
-                                                 (getopt :long-name "with-comments")))))
88
-    ((getopt :long-name "get-issues")
89
-     (let ((options (remainder)))
90
-       (let ((issues (jira-api::json2sheeple (jira-api::get-issues *auth*))))
91
-         (alexandria:if-let ((status (getopt :long-name "status")))
92
-           (setf issues
93
-                 (sheeple:defobject ()
94
-                                    ((jira-api::issues
95
-                                       (apply 'vector
96
-                                              (gethash status
97
-                                                       (jira-api::classify-issues issues))))))))
98
-         (jira-api::show-issues issues))))
99
-    ((getopt :long-name "list-projects") (jira-api::show-projects
100
-                                           (jira-api::json2sheeple
123
+                                                  (getopt :long-name "with-comments")))))
124
+      ((getopt :long-name "get-issues")
125
+       (let ((options (remainder)))
126
+         (let ((issues (jira-api::sort-issues-by-status (jira-api::json2sheeple (get-insights-issues *auth*)
127
+                                                                                jira-api::=issues=))))
128
+           (alexandria:if-let ((status (getopt :long-name "status")))
129
+               (setf issues
130
+                     (sheeple:defobject ()
131
+                         ((jira-api::issues
132
+                           (apply 'vector
133
+                                  (gethash status
134
+                                           (jira-api::classify-issues issues))))))))
135
+           (jira-api::show-issues issues))))
136
+
137
+      ((getopt :long-name "list-projects") (jira-api::show-projects
138
+                                            (jira-api::json2sheeple
101 139
                                              (jira-api::get-projects *auth*))))
102
-    ((getopt :long-name "post-issue") (yason:encode (jira-api::read-issue)))
103
-    (t  (help) (exit))))
140
+      #+nil((getopt :long-name "post-issue") (yason:encode (jira-api::read-issue)))
141
+      (t  (help) (exit)))))
104 142
 
143
+;;#+nil
105 144
 (dump "jira-client" main)