fixing search

This commit is contained in:
nek0 2017-10-21 16:11:56 +02:00
parent a723b0b62a
commit e63c06d28e

View file

@ -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 $