summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-07-13 18:25:46 +0530
committerArun Isaac2022-07-19 17:37:07 +0530
commit759ccc92f9b8f9f3c19fab895ca746b8b3a52c18 (patch)
tree267d9cc9eca3afcd4d22a5c9b4e40dd255b80b46
parente00d944a93c92d401fa85ddf21b60f852bdd41f9 (diff)
downloadtissue-759ccc92f9b8f9f3c19fab895ca746b8b3a52c18.tar.gz
tissue-759ccc92f9b8f9f3c19fab895ca746b8b3a52c18.tar.lz
tissue-759ccc92f9b8f9f3c19fab895ca746b8b3a52c18.zip
web: server: Parse provided search query only once.
* tissue/web/server.scm (matches): Accept parsed search query. (handler): Parse provided search query only once.
-rw-r--r--tissue/web/server.scm31
1 files changed, 15 insertions, 16 deletions
diff --git a/tissue/web/server.scm b/tissue/web/server.scm
index 1868591..a7cacb7 100644
--- a/tissue/web/server.scm
+++ b/tissue/web/server.scm
@@ -239,15 +239,13 @@ operators "
("svg" image/svg+xml)
("txt" text/plain)))
-(define (matches db search-query filter)
- "Return the number of matches in DB for SEARCH-QUERY filtering with
-FILTER query."
+(define (matches db query filter)
+ "Return the number of matches in DB for QUERY filtering with FILTER
+query. QUERY and FILTER are Xapian Query objects."
(MSet-get-matches-estimated
(enquire-mset
(enquire
- db (new-Query (Query-OP-FILTER)
- (parse-query search-query)
- filter))
+ db (new-Query (Query-OP-FILTER) query filter))
#:maximum-items (database-document-count db))))
(define (handler request body hosts state-directory)
@@ -287,12 +285,13 @@ STATE-DIRECTORY."
(sxml->html
(call-with-database (string-append state-directory "/" hostname "/xapian")
(lambda (db)
- (let* ((query (new-Query (Query-OP-FILTER)
- (parse-query search-query)
- (or (assq-ref filter-alist search-type)
- (Query-MatchAll))))
+ (let* ((query (parse-query search-query))
(mset (enquire-mset
- (let ((enquire (enquire db query)))
+ (let* ((query (new-Query (Query-OP-FILTER)
+ query
+ (or (assq-ref filter-alist search-type)
+ (Query-MatchAll))))
+ (enquire (enquire db query)))
;; Sort by recency date (slot
;; 0) when query is strictly
;; boolean.
@@ -315,11 +314,11 @@ STATE-DIRECTORY."
(assq-ref host-parameters 'css)
#:page-uri-path path
#:page-uri-parameters parameters
- #:matches (matches db search-query (Query-MatchAll))
- #:matched-open-issues (matches db search-query (assq-ref filter-alist 'open-issue))
- #:matched-closed-issues (matches db search-query (assq-ref filter-alist 'closed-issue))
- #:matched-documents (matches db search-query (assq-ref filter-alist 'document))
- #:matched-commits (matches db search-query (assq-ref filter-alist 'commit))
+ #:matches (matches db query (Query-MatchAll))
+ #:matched-open-issues (matches db query (assq-ref filter-alist 'open-issue))
+ #:matched-closed-issues (matches db query (assq-ref filter-alist 'closed-issue))
+ #:matched-documents (matches db query (assq-ref filter-alist 'document))
+ #:matched-commits (matches db query (assq-ref filter-alist 'commit))
#:current-search-type search-type))))))))
;; Static files
((let ((file-path