From 1b6973cc9e6b4e9354225c57d62448b9b706c639 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Wed, 13 May 2020 11:53:08 +0200 Subject: messages: Simplify search-bugs. We no longer need to separate between terms and filter sets. --- mumi/messages.scm | 71 +++++++++++++++---------------------------------- mumi/web/controller.scm | 7 ++--- 2 files changed, 23 insertions(+), 55 deletions(-) diff --git a/mumi/messages.scm b/mumi/messages.scm index cba4896..df18c25 100644 --- a/mumi/messages.scm +++ b/mumi/messages.scm @@ -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))) diff --git a/mumi/web/controller.scm b/mumi/web/controller.scm index 290ff6b..346f469 100644 --- a/mumi/web/controller.scm +++ b/mumi/web/controller.scm @@ -91,11 +91,8 @@ (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)) -- cgit v1.2.3