about summary refs log tree commit diff
path: root/org-clubhouse.el
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2018-09-26T15·41-0400
committerGriffin Smith <root@gws.fyi>2018-09-26T15·41-0400
commit1b0b98ec7d3a2acb13ff792d33765a2d1a0a9a3b (patch)
tree5f5d69ff788f42d7c3d74ec6cf452da17d77be16 /org-clubhouse.el
parent1ae8ab35b34f288b7f280197343f1fd1dbe67f55 (diff)
feat: Create org-mode headlines from query
Merges in a function which has existed in my local setup for a while now
to run a query to Clubhouse and create all the results as org headlines
at a specified level
Diffstat (limited to 'org-clubhouse.el')
-rw-r--r--org-clubhouse.el31
1 files changed, 31 insertions, 0 deletions
diff --git a/org-clubhouse.el b/org-clubhouse.el
index 67fec58a443f..33539e2c98f9 100644
--- a/org-clubhouse.el
+++ b/org-clubhouse.el
@@ -728,6 +728,37 @@ allows manually passing a clubhouse ID and list of org-element plists to write"
         (message "Successfully updated clubhouse status to \"%s\""
                  clubhouse-workflow-state)))))
 
+
+(defun org-clubhouse-headlines-from-query (level query)
+  "Create `org-mode' headlines from a clubhouse query.
+
+Submits QUERY to clubhouse, and creates `org-mode' headlines from all the
+resulting stories at headline level LEVEL."
+  (interactive
+   "*nLevel: \nMQuery: ")
+  (let* ((sprint-stories
+          (org-clubhouse-request
+           "GET"
+           "search/stories"
+           :params '((query query))))
+         (sprint-story-list (-> sprint-stories cdr car cdr (append nil))))
+    (save-mark-and-excursion
+      (insert
+       (mapconcat (lambda (story)
+                    (format
+                     "%s TODO %s
+:PROPERTIES:
+:clubhouse-id: %s
+:END:
+"
+                     (make-string level ?*)
+                     (alist-get 'name story)
+                     (let ((story-id (alist-get 'id story)))
+                       (org-make-link-string
+                        (org-clubhouse-link-to-story story-id)
+                        (number-to-string story-id)))))
+                  (reject-archived sprint-story-list) "\n")))))
+
 (define-minor-mode org-clubhouse-mode
   :init-value nil
   :group 'org