aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-08-09 23:25:40 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-08-09 23:25:40 +0200
commitba219981185d90a926d6eff5b4629717133c77d5 (patch)
tree08b998d92b4f4c34ed93f18ec0189be69dcd5253
parentAdd paginator, use in in html and term. (diff)
downloadcalp-ba219981185d90a926d6eff5b4629717133c77d5.tar.gz
calp-ba219981185d90a926d6eff5b4629717133c77d5.tar.xz
Partial search page works, but alway times out first.
-rw-r--r--module/vcomponent/search.scm20
1 files changed, 13 insertions, 7 deletions
diff --git a/module/vcomponent/search.scm b/module/vcomponent/search.scm
index 571279e7..65e2630a 100644
--- a/module/vcomponent/search.scm
+++ b/module/vcomponent/search.scm
@@ -45,13 +45,19 @@
;; 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))
- (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 _ (throw 'timed-out))))
+ (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)))
;; Creates a prepared query wrappend in a paginator.