diff options
author | Arun Isaac <arunisaac@systemreboot.net> | 2022-12-29 20:24:00 +0000 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2022-12-31 19:01:53 +0100 |
commit | a2080ebf931d8c31da8c6f31770b309e15fdf70e (patch) | |
tree | a11dfca6120b606a657753cf1e58dcd2d4338301 | |
parent | 2b47175b7f1712d4f78eac9fd6818f7ffe51dbfb (diff) |
xapian: Preserve order of search results.
Xapian orders search results by relevance. Preserve this order.
* mumi/xapian.scm (search): Reverse search results after consing to
preserve the original order.
* mumi/messages.scm (status-with-cache): Do not sort bugs by their bug
number. Preserve the order of bugs passed to this function.
-rw-r--r-- | mumi/messages.scm | 13 | ||||
-rw-r--r-- | mumi/xapian.scm | 21 |
2 files changed, 15 insertions, 19 deletions
diff --git a/mumi/messages.scm b/mumi/messages.scm index b3ae962..fd52571 100644 --- a/mumi/messages.scm +++ b/mumi/messages.scm @@ -64,15 +64,10 @@ (define (status-with-cache ids) "Invoke GET-STATUS, but only on those IDS that have not been cached yet. Return new results alongside cached results." - (let* ((cached (filter-map cached? ids)) - (uncached-ids (lset-difference eq? - ids - (map bug-num cached))) - (new (filter-map bug-status uncached-ids ))) - ;; Cache new things - (map (lambda (bug) (cache! (bug-num bug) bug)) new) - ;; Return everything from cache - (sort (append cached new) (lambda (a b) (< (bug-num a) (bug-num b)))))) + (map (lambda (id) + (or (cached? id) + (cache! id (bug-status id)))) + ids)) (define (extract-name address) (or (assoc-ref address 'name) diff --git a/mumi/xapian.scm b/mumi/xapian.scm index ae01acc..7ca5bb8 100644 --- a/mumi/xapian.scm +++ b/mumi/xapian.scm @@ -339,16 +339,17 @@ intact." ;; Collapse on mergedwith value (Enquire-set-collapse-key enq 2 1) ;; Fold over the results, return bug id. - (mset-fold (lambda (item acc) - (cons - (document-data (mset-item-document item)) - acc)) - '() - ;; Get an Enquire object from the database with the - ;; search results. Then, extract the MSet from the - ;; Enquire object. - (enquire-mset enq - #:maximum-items pagesize)))))) + (reverse + (mset-fold (lambda (item acc) + (cons + (document-data (mset-item-document item)) + acc)) + '() + ;; Get an Enquire object from the database with the + ;; search results. Then, extract the MSet from the + ;; Enquire object. + (enquire-mset enq + #:maximum-items pagesize))))))) (define* (index! #:key full?) "Index all Debbugs log files corresponding to the selected |