Commit 2f672573 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[Type] Indexed generic and polymorphic type to save database id with core garg types.

parent 55072e33
Pipeline #1329 failed with stage
...@@ -157,14 +157,13 @@ instance (Typeable a, ToSchema a) => ToSchema (TableResult a) where ...@@ -157,14 +157,13 @@ instance (Typeable a, ToSchema a) => ToSchema (TableResult a) where
instance Arbitrary a => Arbitrary (TableResult a) where instance Arbitrary a => Arbitrary (TableResult a) where
arbitrary = TableResult <$> arbitrary <*> arbitrary arbitrary = TableResult <$> arbitrary <*> arbitrary
----------------------------------------------------------------------------
-- TO BE removed -- TO BE removed
data TODO = TODO data TODO = TODO
deriving (Generic) deriving (Generic)
instance ToSchema TODO where instance ToSchema TODO where
instance ToParamSchema TODO where instance ToParamSchema TODO where
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
...@@ -198,11 +198,5 @@ indexNgramsT = fmap . indexNgramsWith . withMap ...@@ -198,11 +198,5 @@ indexNgramsT = fmap . indexNgramsWith . withMap
indexNgrams :: Map NgramsTerms NgramsId -> Ngrams -> (NgramsIndexed Ngrams) indexNgrams :: Map NgramsTerms NgramsId -> Ngrams -> (NgramsIndexed Ngrams)
indexNgrams = indexNgramsWith . withMap indexNgrams = indexNgramsWith . withMap
{-
-- NP: not sure we need it anymore
indexNgramsTWith :: (NgramsTerms -> NgramsId) -> NgramsT Ngrams -> NgramsT (NgramsIndexed
indexNgramsTWith = fmap . indexNgramsWith
-}
indexNgramsWith :: (NgramsTerms -> NgramsId) -> Ngrams -> NgramsIndexed Ngrams indexNgramsWith :: (NgramsTerms -> NgramsId) -> Ngrams -> NgramsIndexed Ngrams
indexNgramsWith f n = NgramsIndexed n (f $ _ngramsTerms n) indexNgramsWith f n = NgramsIndexed n (f $ _ngramsTerms n)
{-|
Module : Gargantext.Database.Types
Description : Specific Types to manage core Gargantext type with database
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE TemplateHaskell #-}
module Gargantext.Database.Types
where
import Gargantext.Prelude
import Gargantext.Database.Schema.Prelude
import qualified Database.PostgreSQL.Simple as PGS
-- | Index memory of any type in Gargantext
type Index = Int
data Indexed a =
Indexed { _unIndex :: a
, _index :: Index
}
deriving (Show, Generic, Eq, Ord)
makeLenses ''Indexed
instance (FromField a) => PGS.FromRow (Indexed a) where
fromRow = Indexed <$> field <*> field
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment