diff --git a/src/Database/Marketplace.hs b/src/Database/Marketplace.hs index 8eaa221..f28b076 100644 --- a/src/Database/Marketplace.hs +++ b/src/Database/Marketplace.hs @@ -39,10 +39,8 @@ import Database.Persist.Postgresql , selectSource , (||.) ) -import Handler.Types.Marketplace ( PackageDependencyMetadata(..) - ) +import Handler.Types.Marketplace ( PackageDependencyMetadata(..) ) import Lib.Types.AppIndex ( PkgId ) -import Lib.Types.Category import Lib.Types.Emver ( Version ) import Model import Startlude hiding ( (%) @@ -51,6 +49,8 @@ import Startlude hiding ( (%) , yield ) +type CategoryTitle = Text + searchServices :: (MonadResource m, MonadIO m) => Maybe CategoryTitle -> Text diff --git a/src/Handler/Marketplace.hs b/src/Handler/Marketplace.hs index 5e06498..e567b87 100644 --- a/src/Handler/Marketplace.hs +++ b/src/Handler/Marketplace.hs @@ -85,7 +85,6 @@ import Lib.PkgRepository ( PkgRepo , getManifest ) import Lib.Types.AppIndex ( PkgId ) -import Lib.Types.Category ( CategoryTitle(..) ) import Lib.Types.Emver ( Version , VersionRange , parseRange diff --git a/src/Handler/Types/Marketplace.hs b/src/Handler/Types/Marketplace.hs index 3708279..9669a5a 100644 --- a/src/Handler/Types/Marketplace.hs +++ b/src/Handler/Types/Marketplace.hs @@ -5,7 +5,6 @@ module Handler.Types.Marketplace where import Data.Aeson import qualified Data.HashMap.Internal.Strict as HM import Lib.Types.AppIndex ( PkgId ) -import Lib.Types.Category ( CategoryTitle ) import Lib.Types.Emver ( Version , VersionRange ) @@ -19,6 +18,7 @@ import Yesod type URL = Text +type CategoryTitle = Text data InfoRes = InfoRes { name :: Text , categories :: [CategoryTitle] diff --git a/src/Lib/Types/Category.hs b/src/Lib/Types/Category.hs deleted file mode 100644 index 20aede7..0000000 --- a/src/Lib/Types/Category.hs +++ /dev/null @@ -1,50 +0,0 @@ -{-# LANGUAGE TemplateHaskell #-} -{-# LANGUAGE QuasiQuotes #-} -{-# LANGUAGE DeriveGeneric #-} - -module Lib.Types.Category where - -import Startlude -import Database.Persist.Postgresql -import Data.Aeson -import Control.Monad -import Yesod.Core - -data CategoryTitle = FEATURED - | BITCOIN - | LIGHTNING - | DATA - | MESSAGING - | SOCIAL - | ALTCOIN - deriving (Eq, Enum, Show, Read, Generic) -instance PersistField CategoryTitle where - fromPersistValue = fromPersistValueJSON - toPersistValue = toPersistValueJSON -instance PersistFieldSql CategoryTitle where - sqlType _ = SqlString -instance ToJSON CategoryTitle where - -- toJSON = String . T.toLower . show - toJSON = \case - FEATURED -> "featured" - BITCOIN -> "bitcoin" - LIGHTNING -> "lightning" - DATA -> "data" - MESSAGING -> "messaging" - SOCIAL -> "social" - ALTCOIN -> "alt coin" -instance FromJSON CategoryTitle where - parseJSON = withText "CategoryTitle" $ \case - "featured" -> pure FEATURED - "bitcoin" -> pure BITCOIN - "lightning" -> pure LIGHTNING - "data" -> pure DATA - "messaging" -> pure MESSAGING - "social" -> pure SOCIAL - "alt coin" -> pure ALTCOIN - _ -> fail "unknown category title" -instance ToContent CategoryTitle where - toContent = toContent . toJSON -instance ToTypedContent CategoryTitle where - toTypedContent = toTypedContent . toJSON -instance Hashable CategoryTitle diff --git a/src/Model.hs b/src/Model.hs index 48472c4..78338ca 100644 --- a/src/Model.hs +++ b/src/Model.hs @@ -13,7 +13,6 @@ module Model where import Database.Persist.TH import Lib.Types.AppIndex -import Lib.Types.Category import Lib.Types.Emver import Orphans.Emver ( ) import Startlude @@ -60,7 +59,7 @@ Metric Category createdAt UTCTime - name CategoryTitle + name Text parent CategoryId Maybe description Text priority Int default=0