fixing search
This commit is contained in:
parent
a723b0b62a
commit
e63c06d28e
1 changed files with 8 additions and 3 deletions
|
@ -20,6 +20,7 @@ import Import
|
|||
|
||||
import qualified Data.Text as T
|
||||
import Data.Maybe (fromJust)
|
||||
import Data.List (sortBy)
|
||||
|
||||
import Database.Persist.Sql (rawSql)
|
||||
|
||||
|
@ -31,11 +32,15 @@ getSearchR = do
|
|||
searchForm
|
||||
case res of
|
||||
FormSuccess query -> do
|
||||
mediumList <- runDB $ (++)
|
||||
rawSql "select ?? from medium where any(string_to_array(title, ' ') % ?"
|
||||
mediumList <- runDB $ do
|
||||
a <- rawSql "select ?? from medium where any(string_to_array(title, ' ') % ?"
|
||||
[PersistText query]
|
||||
rawSql "select ?? from medium where any(string_to_array(description, ' ') % ?"
|
||||
b <- rawSql "select ?? from medium where any(string_to_array(description, ' ') % ?"
|
||||
[PersistText query]
|
||||
return $ sortBy (\ sa sb -> compare
|
||||
(T.unpack $ mediumTitle $ entityVal sa)
|
||||
(T.unpack $ mediumTitle $ entityVal sb))
|
||||
$ a ++ b
|
||||
userList <- runDB $
|
||||
rawSql "select ?? from \"user\" where name % ?" [PersistText query]
|
||||
albumList <- runDB $
|
||||
|
|
Loading…
Reference in a new issue