-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
58 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,25 @@ | ||
module Flora.Search where | ||
|
||
import Data.Text | ||
import Data.Vector (Vector) | ||
|
||
query :: Text -> m [Text] | ||
query _searchString = undefined | ||
import FloraWeb.Server.Auth (FloraPageM) | ||
import Flora.Model.Package (Namespace(..), PackageName) | ||
import Flora.Environment (FloraEnv(..)) | ||
import qualified Flora.Model.Package.Query as Query | ||
import Control.Monad.IO.Class | ||
import Database.PostgreSQL.Entity.DBT (withPool) | ||
import FloraWeb.Session (getSession, Session(..)) | ||
import FloraWeb.Types (fetchFloraEnv) | ||
import Optics.Core | ||
|
||
-- searchPackageByNamespace :: Namespace -> Text -> FloraPageM (Vector Package) | ||
-- searchPackageByNamespace (Namespace namespace) query = undefined | ||
|
||
searchPackageByName :: Text -> FloraPageM (Vector (Namespace, PackageName, Text)) | ||
searchPackageByName queryString = do | ||
session <- getSession | ||
FloraEnv{pool} <- liftIO $ fetchFloraEnv (session ^. #webEnvStore) | ||
results <- liftIO $ withPool pool $ Query.searchPackage queryString | ||
let getInfo = (,,) <$> view _1 <*> view _2 <*> view _3 | ||
pure $ fmap getInfo results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters