aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Allred <code@seanallred.com>2015-01-03 22:51:45 -0500
committerSean Allred <code@seanallred.com>2015-01-03 22:51:45 -0500
commiteeb327e3af94e1118218c129916b8f7165e835ef (patch)
tree415c2f2f2eda72f72fc8a9fbd1af829283dda556
parentd19917d9f152e2eda6b15687dae62f149a3d5779 (diff)
Introduce :page and :pagesize into sx-method-call
Default page size is 100 to reduce number of overall requests made. Fixes #190.
-rw-r--r--sx-method.el6
-rw-r--r--sx-site.el2
-rw-r--r--sx-tag.el8
3 files changed, 10 insertions, 6 deletions
diff --git a/sx-method.el b/sx-method.el
index 64dbc1f..e0764fb 100644
--- a/sx-method.el
+++ b/sx-method.el
@@ -35,6 +35,8 @@
(cl-defun sx-method-call (method &key id
submethod
keywords
+ page
+ (pagesize 100)
(filter '(()))
auth
(url-method "GET")
@@ -55,6 +57,8 @@ authentication.
:SITE is the api parameter specifying the site.
:GET-ALL is nil or non-nil
:PROCESS-FUNCTION is a response-processing function
+:PAGE is the page number which will be requested
+:PAGESIZE is the number of items to retrieve per request, default 100
When AUTH is nil, it is assumed that no auth-requiring filters or
methods will be used. If they are an error will be signaled. This is
@@ -123,6 +127,8 @@ Return the entire response as a complex alist."
(error "This request requires authentication."))))
;; Concatenate all parameters now that filter is ensured.
(push `(filter . ,(sx-filter-get-var filter)) keywords)
+ (push `(page . ,page) keywords)
+ (push `(pagesize . ,pagesize) keywords)
(when site
(push `(site . ,site) keywords))
(funcall call
diff --git a/sx-site.el b/sx-site.el
index 8bd4fc0..1402bb9 100644
--- a/sx-site.el
+++ b/sx-site.el
@@ -49,7 +49,7 @@
(sx-cache-get
'site-list
'(sx-method-call 'sites
- :keywords '((pagesize . 999))
+ :pagesize 999
:filter sx-site-browse-filter)))
(defcustom sx-site-favorites
diff --git a/sx-tag.el b/sx-tag.el
index e9d3f4f..07b7a77 100644
--- a/sx-tag.el
+++ b/sx-tag.el
@@ -39,8 +39,7 @@
(sx-method-call 'tags
:get-all t
:filter sx-tag-filter
- :site site
- :keywords '((pagesize . 100)))))
+ :site site)))
(defun sx-tag--get-some-tags-containing (site string)
"Return at most 100 tags for SITE containing STRING.
@@ -49,7 +48,7 @@ Returns an array."
:auth nil
:filter sx-tag-filter
:site site
- :keywords `((page . 1) (pagesize . 100) (inname . ,string))))
+ :keywords `((inname . ,string))))
(defun sx-tag--get-some-tag-names-containing (site string)
"Return at most 100 tag names for SITE containing STRING.
@@ -74,8 +73,7 @@ Return the list of invalid tags in TAGS."
:submethod 'info
:auth nil
:filter sx-tag-filter
- :site site
- :keywords '((page . 1) (pagesize . 100))))))
+ :site site))))
(cl-remove-if (lambda (x) (member x result)) tags)))
(provide 'sx-tag)