forked from cadence/breezewiki
Fix failing test after search was refactored
This commit is contained in:
parent
b8a6c5198d
commit
b02e2a4053
3 changed files with 12 additions and 10 deletions
|
@ -25,8 +25,8 @@
|
|||
page-search)
|
||||
|
||||
(define search-providers
|
||||
(hash "fandom" generate-results-content-fandom
|
||||
"solr" generate-results-content-solr))
|
||||
(hash "fandom" search-fandom
|
||||
"solr" search-solr))
|
||||
|
||||
;; this takes the info we gathered from fandom and makes the big fat x-expression page
|
||||
(define (generate-results-page req source-url wikiname query results-content #:siteinfo [siteinfo #f])
|
||||
|
|
|
@ -8,15 +8,15 @@
|
|||
"../lib/xexpr-utils.rkt")
|
||||
|
||||
(provide
|
||||
generate-results-content-fandom)
|
||||
search-fandom)
|
||||
|
||||
(module+ test
|
||||
(require rackunit
|
||||
"test-utils.rkt")
|
||||
(define search-json-data
|
||||
'#hasheq((batchcomplete . #t) (query . #hasheq((search . (#hasheq((ns . 0) (pageid . 219) (size . 1482) (snippet . "") (timestamp . "2022-08-21T08:54:23Z") (title . "Gacha Capsule") (wordcount . 214)) #hasheq((ns . 0) (pageid . 201) (size . 1198) (snippet . "") (timestamp . "2022-07-11T17:52:47Z") (title . "Badges") (wordcount . 181)))))))))
|
||||
(define search-results-data
|
||||
'(#hasheq((ns . 0) (pageid . 219) (size . 1482) (snippet . "") (timestamp . "2022-08-21T08:54:23Z") (title . "Gacha Capsule") (wordcount . 214)) #hasheq((ns . 0) (pageid . 201) (size . 1198) (snippet . "") (timestamp . "2022-07-11T17:52:47Z") (title . "Badges") (wordcount . 181)))))
|
||||
|
||||
(define (generate-results-content-fandom wikiname query params)
|
||||
(define (search-fandom wikiname query params)
|
||||
;; constructing the URL where I want to get fandom data from...
|
||||
(define origin (format "https://~a.fandom.com" wikiname))
|
||||
;; the dest-URL will look something like https://minecraft.fandom.com/api.php?action=query&list=search&srsearch=Spawner&formatversion=2&format=json
|
||||
|
@ -33,8 +33,10 @@
|
|||
(define res (easy:get dest-url #:timeouts timeouts))
|
||||
(define json (easy:response-json res))
|
||||
(define search-results (jp "/query/search" json))
|
||||
(generate-results-content-fandom wikiname query search-results))
|
||||
|
||||
;; generate content for display in the wiki page layout
|
||||
;;; generate content for display in the wiki page layout
|
||||
(define (generate-results-content-fandom wikiname query search-results)
|
||||
`(div (@ (class "mw-parser-output"))
|
||||
;; header before the search results showing how many we found
|
||||
(p ,(format "~a results found for " (length search-results))
|
||||
|
@ -60,4 +62,4 @@
|
|||
(module+ test
|
||||
(parameterize ([(config-parameter 'feature_offline::only) "false"])
|
||||
(check-not-false ((query-selector (attribute-selector 'href "/test/wiki/Gacha_Capsule")
|
||||
(generate-results-content-fandom test-req "" "test" "Gacha" search-json-data))))))
|
||||
(generate-results-content-fandom "test" "Gacha" search-results-data))))))
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
"../lib/xexpr-utils.rkt")
|
||||
|
||||
(provide
|
||||
generate-results-content-solr)
|
||||
search-solr)
|
||||
|
||||
(struct result^ (hl-title hl-body kb words page-path) #:transparent)
|
||||
|
||||
(define (generate-results-content-solr wikiname query params)
|
||||
(define (search-solr wikiname query params)
|
||||
;; grab things from params that would modify the search
|
||||
(define op (if (equal? (dict-ref params 'op #f) "or") '("or" . "OR") '("and" . "AND")))
|
||||
(define sort (if (equal? (dict-ref params 'sort #f) "len") '("len" . "len desc") '("relevance" . "score desc")))
|
||||
|
|
Loading…
Reference in a new issue