controller: Fetch more messages if we need to filter locally.
authorRicardo Wurmus <rekado@elephly.net>
Sun, 2 Sep 2018 20:35:10 +0000 (22:35 +0200)
committerRicardo Wurmus <rekado@elephly.net>
Sun, 2 Sep 2018 20:35:10 +0000 (22:35 +0200)
mumi/web/controller.scm

index 5d9ea17..d19e961 100644 (file)
           (lambda ()
             (list-of-matching-bugs query
                                    (match (process-query query)
+                                     ((#:terms terms
+                                       #:attributes attrs
+                                       #:filters '())
+                                      (search-bugs (string-join terms)
+                                                   #:attributes attrs))
+                                     ;; Fetch more messages if there
+                                     ;; are local filters to increase
+                                     ;; the chance of finding some
+                                     ;; that pass the filter.
                                      ((#:terms terms
                                        #:attributes attrs
                                        #:filters fs)
-                                      (filter (lambda (bug)
-                                                (every (lambda (f) (f bug)) fs))
-                                              (search-bugs (string-join terms)
-                                                           #:attributes attrs))))))
+                                      (let ((str (string-join terms)))
+                                        (filter (lambda (bug)
+                                                  (every (lambda (f) (f bug)) fs))
+                                                (search-bugs (string-join terms)
+                                                             #:attributes attrs
+                                                             #:max 800)))))))
           `(p "Could not search for " (strong ,query) "."))))))
     ((GET "issue" (? string->number id))
      (render-with-error-handling