From f67581bea9216b8d0b624de3673c718073b9d6b6 Mon Sep 17 00:00:00 2001 From: Yoni Rabkin Date: Thu, 11 Dec 2014 15:38:50 -0500 Subject: Implement and start using REST show query. At this point the most basic functionality of rt-liberation, that of listing tickets in response to a query, is using the REST interface. --- rt-liberation-rest.el | 24 ++++++++++++++++++------ rt-liberation.el | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/rt-liberation-rest.el b/rt-liberation-rest.el index a13b039..2121aba 100644 --- a/rt-liberation-rest.el +++ b/rt-liberation-rest.el @@ -108,7 +108,6 @@ (defun rt-liber-rest-query-runner (op query-string) "Run OP on QUERY-STRING." - (message "starting REST '%s' query at %s..." op (current-time-string)) (when (or (not (stringp op)) (not (stringp query-string))) (error "bad arguments")) @@ -157,6 +156,16 @@ (rt-liber-rest-query-runner "ls" query) 'rt-liber-rest-ticketsql-runner-parser-f)) +(defun rt-liber-rest-show-process (response) + "Process and return the show query response." + (when (not (stringp response)) + (error "argument not a string")) + (with-temp-buffer + (save-excursion + (insert response)) + (rt-liber-rest-parse-http-header) + (buffer-substring (point) (point-max)))) + (defun rt-liber-rest-show-query-runner (idsublist) "Iterate over IDSUBLIST and return the collected result." (when (not (listp idsublist)) @@ -172,15 +181,18 @@ (setq c (1+ c))) (insert - (rt-liber-rest-query-runner "show" (caar ticket-ids))) - (setq ticket-ids (cdr ticket-ids)))) + (rt-liber-rest-show-process + (rt-liber-rest-query-runner "show" (caar ticket-ids)))) + (setq ticket-ids (cdr ticket-ids)) + (when ticket-ids + (insert "\n--\n")))) (buffer-substring (point-min) (point-max)))) (defun rt-liber-rest-run-show-base-query (idsublist) "Run \"show\" type query against the server with IDSUBLIST." - ;;(rt-liber-parse-answer - (rt-liber-rest-show-query-runner idsublist)) -;;#'rt-liber-ticket-base-retriever-parser-f)) + (rt-liber-parse-answer + (rt-liber-rest-show-query-runner idsublist) + #'rt-liber-ticket-base-retriever-parser-f)) (provide 'rt-liberation-rest) diff --git a/rt-liberation.el b/rt-liberation.el index 532e034..c7a3a33 100644 --- a/rt-liberation.el +++ b/rt-liberation.el @@ -1077,7 +1077,7 @@ string then that will be the name of the new buffer." (interactive "Mquery: ") (condition-case excep (rt-liber-browser-startup - (rt-liber-run-show-base-query + (rt-liber-rest-run-show-base-query (rt-liber-rest-run-ls-query query)) query new) (rt-liber-no-result-from-query-error -- cgit v1.2.3