diff options
author | Sean Allred <code@seanallred.com> | 2015-01-03 22:51:45 -0500 |
---|---|---|
committer | Sean Allred <code@seanallred.com> | 2015-01-03 22:51:45 -0500 |
commit | eeb327e3af94e1118218c129916b8f7165e835ef (patch) | |
tree | 415c2f2f2eda72f72fc8a9fbd1af829283dda556 | |
parent | d19917d9f152e2eda6b15687dae62f149a3d5779 (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.el | 6 | ||||
-rw-r--r-- | sx-site.el | 2 | ||||
-rw-r--r-- | sx-tag.el | 8 |
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 @@ -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 @@ -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) |