aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-08-10 11:26:53 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-08-10 11:26:53 +0200
commitff43c256ed800d5400076276970536bab7435dfe (patch)
treeb77cd95b075821a72c63d58552264d53a9ca2f3b
parentAdd stream-timeslice-limit. (diff)
downloadcalp-ff43c256ed800d5400076276970536bab7435dfe.tar.gz
calp-ff43c256ed800d5400076276970536bab7435dfe.tar.xz
Remove old limiter on execute-query.
-rw-r--r--module/vcomponent/search.scm27
1 files changed, 12 insertions, 15 deletions
diff --git a/module/vcomponent/search.scm b/module/vcomponent/search.scm
index d240cbdc..74c5a8aa 100644
--- a/module/vcomponent/search.scm
+++ b/module/vcomponent/search.scm
@@ -45,27 +45,24 @@
;; execute a query procedure created by build-query-proc.
;; (event → bool), int, (optional int) → (list event) throws 'timed-out
(define* (execute-query query page key: (time-limit 1))
- (let ((lst '()))
- (call-with-time-limit
- time-limit
- ;; Stream->list needs to be here, since the actual
- ;; stream-force needs to happen within the actual
- ;; @var{call-with-time-limit}.
- (lambda ()
- (let loop ((strm (stream-ref query page)))
- (if (stream-null? strm) lst
- (set! lst (cons (stream-car strm) lst))
- (loop (stream-cdr strm)))))
- (lambda _ (format (current-error-port) "~a~%" 'timed-out)))
- (reverse lst)))
+ (call-with-time-limit
+ time-limit
+ ;; Stream->list needs to be here, since the actual
+ ;; stream-force needs to happen within the actual
+ ;; @var{call-with-time-limit}.
+ (lambda () (stream->list (stream-ref query page)))
+ (lambda _ (format (current-error-port) "~a~%" 'timed-out)
+ (throw 'timed-out)))
+)
;; Creates a prepared query wrappend in a paginator.
;; (event → bool), (stream event) → <paginator>
-(define-public (prepare-query query-proc event-set)
+(define*-public (prepare-query query-proc event-set optional: (page-size 10))
(make-paginator (stream-paginate
(stream-timeslice-limit
- (stream-filter query-proc event-set)))))
+ (stream-filter query-proc event-set))
+ page-size)))
(define-record-type <paginator>
(make-paginator% query max-page true-max-page?)