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 qualified Data.Text as T
|
||||||
import Data.Maybe (fromJust)
|
import Data.Maybe (fromJust)
|
||||||
|
import Data.List (sortBy)
|
||||||
|
|
||||||
import Database.Persist.Sql (rawSql)
|
import Database.Persist.Sql (rawSql)
|
||||||
|
|
||||||
|
@ -31,11 +32,15 @@ getSearchR = do
|
||||||
searchForm
|
searchForm
|
||||||
case res of
|
case res of
|
||||||
FormSuccess query -> do
|
FormSuccess query -> do
|
||||||
mediumList <- runDB $ (++)
|
mediumList <- runDB $ do
|
||||||
rawSql "select ?? from medium where any(string_to_array(title, ' ') % ?"
|
a <- rawSql "select ?? from medium where any(string_to_array(title, ' ') % ?"
|
||||||
[PersistText query]
|
[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]
|
[PersistText query]
|
||||||
|
return $ sortBy (\ sa sb -> compare
|
||||||
|
(T.unpack $ mediumTitle $ entityVal sa)
|
||||||
|
(T.unpack $ mediumTitle $ entityVal sb))
|
||||||
|
$ a ++ b
|
||||||
userList <- runDB $
|
userList <- runDB $
|
||||||
rawSql "select ?? from \"user\" where name % ?" [PersistText query]
|
rawSql "select ?? from \"user\" where name % ?" [PersistText query]
|
||||||
albumList <- runDB $
|
albumList <- runDB $
|
||||||
|
|
Loading…
Reference in a new issue