Commit 37fb1b8c authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FEAT] update backend (WIP)

parent cc45f765
......@@ -42,7 +42,9 @@ import Gargantext.API.Metrics
import Gargantext.API.Ngrams (TabType(..), TableNgramsApi, apiNgramsTableCorpus, QueryParamR)
import Gargantext.API.Ngrams.NTree (MyTree)
import Gargantext.API.Node.New
import qualified Gargantext.API.Node.Share as Share
import qualified Gargantext.API.Node.Share as Share
import qualified Gargantext.API.Node.Update as Update
import Gargantext.API.Search (SearchDocsAPI, searchDocs, SearchPairsAPI, searchPairs)
import Gargantext.API.Table
import Gargantext.Core.Types (NodeTableResult)
......@@ -126,6 +128,7 @@ type NodeAPI a = Get '[JSON] (Node a)
:<|> "table" :> TableApi
:<|> "ngrams" :> TableNgramsApi
:<|> "update" :> Update.API
:<|> "category" :> CatApi
:<|> "search" :> SearchDocsAPI
:<|> "share" :> Share.API
......@@ -199,9 +202,9 @@ nodeAPI p uId id' = withAccess (Proxy :: Proxy (NodeAPI a)) Proxy uId (PathNode
-- TODO gather it
:<|> tableApi id'
:<|> apiNgramsTableCorpus id'
:<|> Update.api id'
:<|> catApi id'
:<|> searchDocs id'
:<|> Share.api id'
-- Pairing Tools
......
{-|
Module : Gargantext.API.Node.Update
Description :
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Gargantext.API.Node.Update
where
import Prelude (Enum, Bounded, minBound, maxBound)
import Data.Aeson
import Data.Swagger
import GHC.Generics (Generic)
import Gargantext.Database.Admin.Types.Node
import Gargantext.Database.Prelude
import Gargantext.Database.Query.Table.Node.Error (HasNodeError(..))
import Gargantext.Prelude
import Servant
import Test.QuickCheck (elements)
import Test.QuickCheck.Arbitrary
------------------------------------------------------------------------
data UpdateNodeParams = UpdateNodeParamsList { methodList :: Method }
| UpdateNodeParamsGraph { methodGraph :: Metric }
| UpdateNodeParamsTexts { methodTexts :: Granularity }
| UpdateNodeParamsBoard { methodBoard :: Charts }
deriving (Generic)
----------------------------------------------------------------------
data Method = Basic | Advanced | WithModel
deriving (Generic, Eq, Ord, Enum, Bounded)
----------------------------------------------------------------------
data Metric = Order1 | Order2
deriving (Generic, Eq, Ord, Enum, Bounded)
----------------------------------------------------------------------
data Granularity = NewNgrams | NewTexts | Both
deriving (Generic, Eq, Ord, Enum, Bounded)
----------------------------------------------------------------------
data Charts = Sources | Authors | Institutes | Ngrams | All
deriving (Generic, Eq, Ord, Enum, Bounded)
------------------------------------------------------------------------
-- TODO unPrefix "pn_" FromJSON, ToJSON, ToSchema, adapt frontend.
instance FromJSON UpdateNodeParams
instance ToJSON UpdateNodeParams
instance ToSchema UpdateNodeParams
instance Arbitrary UpdateNodeParams where
arbitrary = do
l <- UpdateNodeParamsList <$> arbitrary
g <- UpdateNodeParamsGraph <$> arbitrary
t <- UpdateNodeParamsTexts <$> arbitrary
b <- UpdateNodeParamsBoard <$> arbitrary
elements [l,g,t,b]
instance FromJSON Method
instance ToJSON Method
instance ToSchema Method
instance Arbitrary Method where
arbitrary = elements [ minBound .. maxBound ]
instance FromJSON Metric
instance ToJSON Metric
instance ToSchema Metric
instance Arbitrary Metric where
arbitrary = elements [ minBound .. maxBound ]
instance FromJSON Granularity
instance ToJSON Granularity
instance ToSchema Granularity
instance Arbitrary Granularity where
arbitrary = elements [ minBound .. maxBound ]
instance FromJSON Charts
instance ToJSON Charts
instance ToSchema Charts
instance Arbitrary Charts where
arbitrary = elements [ minBound .. maxBound ]
------------------------------------------------------------------------
api :: HasNodeError err
=> NodeId
-> UpdateNodeParams
-> Cmd err Int
api _nId (UpdateNodeParamsList _meth) = pure 1
api _nId (UpdateNodeParamsGraph _meth) = pure 1
api _nId (UpdateNodeParamsTexts _meth) = pure 1
api _nId (UpdateNodeParamsBoard _meth) = pure 1
------------------------------------------------------------------------
type API = Summary " Share Node with username"
:> ReqBody '[JSON] UpdateNodeParams
:> Post '[JSON] Int
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