Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix author search not working since last stable #1087

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ All notable changes to this project will be documented in this file.
### Removed
### Fixed

- [web] authors search returning no results #1082

## [1.10.0] - 2023-11-06

### Added
Expand Down
9 changes: 6 additions & 3 deletions src/Monocle/Api/ServerHTMX.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ searchAuthorsHandler :: ApiEffects es => AuthResult AuthenticatedUser -> Maybe C
searchAuthorsHandler _ Nothing _ = pure $ pure ()
searchAuthorsHandler auth (Just index) queryM = do
case queryM of
Just query -> do
Just authorName -> do
logInfo "Search request for author" ["author" .= authorName, "index" .= index]
(SearchPB.AuthorResponse results) <-
searchAuthor auth (AuthorRequest (from index) (from query))
searchAuthor auth (AuthorRequest (from index) (from authorName))
case toList results of
[] -> pure $ div_ "No Results"
_xs -> pure $ mapM_ authorToMarkup results
Expand All @@ -47,14 +48,16 @@ searchAuthorsHandler auth (Just index) queryM = do
, class_ "pf-c-form-control"
, placeholder_ "Start typing to search authors"
, hxGet "/htmx/authors_search"
, hxVals [iii|{"index": "#{index}"}|]
, hxVals [iii|{"index": "#{indexVal}"}|]
, hxTrigger "keyup changed delay:500ms, search"
, hxTarget "#search-results"
]
div_ [class_ "pf-l-stack__item"] $ do
div_ [id_ "search-results"] ""
script_ pushToRouter
where
indexVal :: Text
indexVal = from index
countCachedAuthors = do
resp <- esCountByIndex (tenantIndexName index) $ BH.CountQuery $ documentType ECachedAuthor
case resp of
Expand Down
Loading