messages: Simplify search-bugs.
authorRicardo Wurmus <rekado@elephly.net>
Wed, 13 May 2020 09:53:08 +0000 (11:53 +0200)
committerRicardo Wurmus <rekado@elephly.net>
Wed, 13 May 2020 09:53:08 +0000 (11:53 +0200)
We no longer need to separate between terms and filter sets.

mumi/messages.scm
mumi/web/controller.scm

index cba4896cd31a95d520307944e1acb4c7e4070b3d..df18c252ca95e87f6621540ed2476ae1f6e0fc8a 100644 (file)
@@ -256,54 +256,25 @@ sets that need to overlap the result set."
                   ((? punctuation? c) #\space)
                   (c c))
                 term))
-  (fold (lambda (term acc)
-          (match acc
-            ((#:terms terms
-              #:sets fs)
-             (match (string-split term #\:)
-               (("is" (or "done" "closed"))
-                `(#:terms ,terms
-                  #:sets ,(cons (db:bugs-by-status "done") fs)))
-               (("is" (or "open" "pending"))
-                `(#:terms ,terms
-                  #:sets ,(cons (db:bugs-by-status "open") fs)))
-               (("date" when)
-                `(#:terms ,(cons (string-append "date:" when) terms)
-                  #:sets ,fs))
-               ;; TODO: this should only be the title of the bug, not
-               ;; the subject.
-               (("title" title)
-                `(#:terms
-                  ,(cons (string-append "subject:" (clean-term title))
-                         terms)
-                  #:sets ,fs))
-               (("subject" subject)
-                `(#:terms
-                  ,(cons (string-append "subject:" (clean-term subject))
-                         terms)
-                  #:sets ,fs))
-               (("tag" tag)
-                `(#:terms ,terms
-                  #:sets
-                  ,(cons (db:bugs-by-tag (clean-term tag)) fs)))
-               (("author" who)
-                `(#:terms
-                  ,(cons (string-append "from:" (clean-term who)) terms)
-                  #:sets ,fs))
-               (("owner" who)
-                `(#:terms ,terms
-                  #:sets ,(cons (db:bugs-by-owner who) fs)))
-               (("submitter" who)
-                `(#:terms ,(cons (string-append "submitter:" who) terms)
-                  #:sets ,fs))
-               (("severity" level)
-                `(#:terms ,terms
-                  #:sets ,(cons (db:bugs-by-severity level) fs)))
-               ((whatever term)
-                `(#:terms ,(cons (clean-term term) terms)
-                  #:sets ,fs))
-               (_
-                `(#:terms ,(cons (clean-term term) terms)
-                  #:sets ,fs))))))
-        '(#:terms () #:sets ())
+  (fold (lambda (term terms)
+          (match (string-split term #\:)
+            (("is" (or "done" "closed"))
+             (cons "status:done" terms))
+            (("is" (or "open" "pending"))
+             (cons "status:open" terms))
+            (((and (or "date" "subject" "tag"
+                       "author" "owner" "submitter"
+                       "severity")
+                   prefix) value)
+             (cons (string-append prefix ":"
+                                  (clean-term value))
+                   terms))
+            ;; TODO: this should only be the title of the bug, not
+            ;; the subject.
+            (("title" title)
+             (cons (string-append "subject:" (clean-term title))
+                   terms))
+            (_
+             (cons (clean-term term) terms))))
+        '()
         (tokenize query)))
index 290ff6beda4f4ee15d48f2cd71e67e7f73e61c3e..346f46947a733656b73ad1e4e99e15cb82662da9 100644 (file)
         (else
          (render-html
           (list-of-matching-bugs query
-                                 (match (process-query query)
-                                   ((#:terms terms
-                                     #:sets s)
-                                    (search-bugs (string-join terms)
-                                                 #:sets s)))))))))
+                                 (search-bugs (string-join
+                                               (process-query query)))))))))
     ((or ('GET "issue" (? string->number id))
          ('GET (? string->number id)))
      (let ((bug (fetch-bug id))