mirror of
https://github.com/Start9Labs/registry.git
synced 2026-04-04 13:49:43 +00:00
remove category enum (#97)
* remove category enum * priority inversion, 0 is always first * set marketplace name default to something more obviously wrong.
This commit is contained in:
committed by
GitHub
parent
75663b65e4
commit
cdadae707c
@@ -35,6 +35,7 @@ registry-hostname: "_env:REGISTRY_HOSTNAME:alpha-registry.start9labs.com"
|
|||||||
tor-port: "_env:TOR_PORT:447"
|
tor-port: "_env:TOR_PORT:447"
|
||||||
static-bin-dir: "_env:STATIC_BIN:/usr/local/bin/"
|
static-bin-dir: "_env:STATIC_BIN:/usr/local/bin/"
|
||||||
error-log-root: "_env:ERROR_LOG_ROOT:/var/log/embassy-os/"
|
error-log-root: "_env:ERROR_LOG_ROOT:/var/log/embassy-os/"
|
||||||
|
marketplace-name: "_env:MARKETPLACE_NAME:CHANGE ME"
|
||||||
|
|
||||||
database:
|
database:
|
||||||
database: "_env:PG_DATABASE:start9_registry"
|
database: "_env:PG_DATABASE:start9_registry"
|
||||||
|
|||||||
@@ -39,10 +39,8 @@ import Database.Persist.Postgresql
|
|||||||
, selectSource
|
, selectSource
|
||||||
, (||.)
|
, (||.)
|
||||||
)
|
)
|
||||||
import Handler.Types.Marketplace ( PackageDependencyMetadata(..)
|
import Handler.Types.Marketplace ( PackageDependencyMetadata(..) )
|
||||||
)
|
|
||||||
import Lib.Types.AppIndex ( PkgId )
|
import Lib.Types.AppIndex ( PkgId )
|
||||||
import Lib.Types.Category
|
|
||||||
import Lib.Types.Emver ( Version )
|
import Lib.Types.Emver ( Version )
|
||||||
import Model
|
import Model
|
||||||
import Startlude hiding ( (%)
|
import Startlude hiding ( (%)
|
||||||
@@ -51,6 +49,8 @@ import Startlude hiding ( (%)
|
|||||||
, yield
|
, yield
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type CategoryTitle = Text
|
||||||
|
|
||||||
searchServices :: (MonadResource m, MonadIO m)
|
searchServices :: (MonadResource m, MonadIO m)
|
||||||
=> Maybe CategoryTitle
|
=> Maybe CategoryTitle
|
||||||
-> Text
|
-> Text
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ import Database.Esqueleto.Experimental
|
|||||||
( Entity(entityKey, entityVal)
|
( Entity(entityKey, entityVal)
|
||||||
, SqlBackend
|
, SqlBackend
|
||||||
, (^.)
|
, (^.)
|
||||||
|
, asc
|
||||||
, desc
|
, desc
|
||||||
, from
|
, from
|
||||||
, orderBy
|
, orderBy
|
||||||
@@ -85,7 +86,6 @@ import Lib.PkgRepository ( PkgRepo
|
|||||||
, getManifest
|
, getManifest
|
||||||
)
|
)
|
||||||
import Lib.Types.AppIndex ( PkgId )
|
import Lib.Types.AppIndex ( PkgId )
|
||||||
import Lib.Types.Category ( CategoryTitle(..) )
|
|
||||||
import Lib.Types.Emver ( Version
|
import Lib.Types.Emver ( Version
|
||||||
, VersionRange
|
, VersionRange
|
||||||
, parseRange
|
, parseRange
|
||||||
@@ -138,7 +138,7 @@ getInfoR = do
|
|||||||
name <- getsYesod $ marketplaceName . appSettings
|
name <- getsYesod $ marketplaceName . appSettings
|
||||||
allCategories <- runDB $ select $ do
|
allCategories <- runDB $ select $ do
|
||||||
cats <- from $ table @Category
|
cats <- from $ table @Category
|
||||||
orderBy [desc (cats ^. CategoryPriority)]
|
orderBy [asc (cats ^. CategoryPriority)]
|
||||||
pure cats
|
pure cats
|
||||||
pure $ InfoRes name $ categoryName . entityVal <$> allCategories
|
pure $ InfoRes name $ categoryName . entityVal <$> allCategories
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ module Handler.Types.Marketplace where
|
|||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
import qualified Data.HashMap.Internal.Strict as HM
|
import qualified Data.HashMap.Internal.Strict as HM
|
||||||
import Lib.Types.AppIndex ( PkgId )
|
import Lib.Types.AppIndex ( PkgId )
|
||||||
import Lib.Types.Category ( CategoryTitle )
|
|
||||||
import Lib.Types.Emver ( Version
|
import Lib.Types.Emver ( Version
|
||||||
, VersionRange
|
, VersionRange
|
||||||
)
|
)
|
||||||
@@ -19,6 +18,7 @@ import Yesod
|
|||||||
|
|
||||||
|
|
||||||
type URL = Text
|
type URL = Text
|
||||||
|
type CategoryTitle = Text
|
||||||
data InfoRes = InfoRes
|
data InfoRes = InfoRes
|
||||||
{ name :: Text
|
{ name :: Text
|
||||||
, categories :: [CategoryTitle]
|
, categories :: [CategoryTitle]
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -13,7 +13,6 @@ module Model where
|
|||||||
|
|
||||||
import Database.Persist.TH
|
import Database.Persist.TH
|
||||||
import Lib.Types.AppIndex
|
import Lib.Types.AppIndex
|
||||||
import Lib.Types.Category
|
|
||||||
import Lib.Types.Emver
|
import Lib.Types.Emver
|
||||||
import Orphans.Emver ( )
|
import Orphans.Emver ( )
|
||||||
import Startlude
|
import Startlude
|
||||||
@@ -60,7 +59,7 @@ Metric
|
|||||||
|
|
||||||
Category
|
Category
|
||||||
createdAt UTCTime
|
createdAt UTCTime
|
||||||
name CategoryTitle
|
name Text
|
||||||
parent CategoryId Maybe
|
parent CategoryId Maybe
|
||||||
description Text
|
description Text
|
||||||
priority Int default=0
|
priority Int default=0
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ instance FromJSON AppSettings where
|
|||||||
let sslCertLocation = sslPath </> "certificate.pem"
|
let sslCertLocation = sslPath </> "certificate.pem"
|
||||||
let registryVersion = fromJust . parseMaybe parseJSON . String . toS . showVersion $ version
|
let registryVersion = fromJust . parseMaybe parseJSON . String . toS . showVersion $ version
|
||||||
|
|
||||||
marketplaceName <- o .:? "marketplace-name" .!= "Start9 Embassy Marketplace"
|
marketplaceName <- o .: "marketplace-name"
|
||||||
|
|
||||||
return AppSettings { .. }
|
return AppSettings { .. }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user