Commit 6651d0d6 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[API][NGRAMS] to discuss

parent 30aae72b
......@@ -97,10 +97,6 @@ data NgramsTable = NgramsTable { _ngramsTable :: [Tree NgramsElement] }
$(deriveJSON (unPrefix "_") ''NgramsTable)
-- TODO
instance FromJSON (Tree NgramsElement)
instance ToJSON (Tree NgramsElement)
------------------------------------------------------------------------
-- On the Client side:
--data Action = InGroup NgramsId NgramsId
......@@ -145,7 +141,6 @@ instance ToSchema NgramsIdPatchs
instance Arbitrary NgramsIdPatchs where
arbitrary = NgramsIdPatchs <$> arbitrary
------------------------------------------------------------------------
------------------------------------------------------------------------
type Version = Int
......@@ -178,11 +173,16 @@ ngramsIdPatch = fromList $ catMaybes $ reverse [ replace (1::NgramsId) (Just $ n
------------------------------------------------------------------------
------------------------------------------------------------------------
type CorpusId = Int
type TableNgramsApi = Summary " Table Ngrams API"
type TableNgramsApi = Summary " Table Ngrams API Change"
:> QueryParam "list" ListId
:> ReqBody '[JSON] NgramsIdPatchs
:> Put '[JSON] NgramsIdPatchsBack
type TableNgramsApiGet = Summary " Table Ngrams API Get"
:> QueryParam "ngramsType" TabType
:> QueryParam "list" ListId
:> Get '[JSON] NgramsIdPatchsBack
type NgramsIdPatchsFeed = NgramsIdPatchs
type NgramsIdPatchsBack = NgramsIdPatchs
......@@ -219,3 +219,5 @@ tableNgramsPatch conn corpusId maybeList patchs = do
_ <- updateNodeNgrams conn (toLists listId patchs)
pure (NgramsIdPatchs [])
getTableNgramsPatch :: Connection -> CorpusId -> Maybe TabType -> Maybe ListId -> IO NgramsTable
getTableNgramsPatch = undefined
......@@ -48,7 +48,7 @@ import Database.PostgreSQL.Simple (Connection)
import GHC.Generics (Generic)
import Servant
import Gargantext.API.Ngrams (TabType(..), TableNgramsApi, tableNgramsPatch, NgramsIdPatchsFeed, NgramsIdPatchsBack)
import Gargantext.API.Ngrams (TabType(..), TableNgramsApi, TableNgramsApiGet,tableNgramsPatch, getTableNgramsPatch, NgramsIdPatchsFeed, NgramsIdPatchsBack)
import Gargantext.Prelude
import Gargantext.Database.Types.Node
import Gargantext.Database.Node ( runCmd
......@@ -110,6 +110,7 @@ type NodeAPI a = Get '[JSON] (Node a)
-- TODO gather it
:<|> "table" :> TableApi
:<|> "list" :> TableNgramsApi
:<|> "listGet" :> TableNgramsApiGet
:<|> "chart" :> ChartApi
:<|> "favorites" :> FavApi
......@@ -142,7 +143,8 @@ nodeAPI conn p id
-- TODO gather it
:<|> getTable conn id
:<|> tableNgramsPatch' conn id
:<|> getTableNgramsPatch' conn id
:<|> getChart conn id
:<|> favApi conn id
:<|> delDocs conn id
......@@ -233,7 +235,6 @@ type ChartApi = Summary " Chart API"
-- To launch a query and update the corpus
-- :<|> "query" :> Capture "string" Text :> Get '[JSON] Text
------------------------------------------------------------------------
type GraphAPI = Get '[JSON] Graph
graphAPI :: Connection -> NodeId -> Server GraphAPI
......@@ -288,6 +289,9 @@ getNodesWith' conn id p nodeType offset limit = liftIO (getNodesWith conn id p
tableNgramsPatch' :: Connection -> CorpusId -> Maybe ListId -> NgramsIdPatchsFeed -> Handler NgramsIdPatchsBack
tableNgramsPatch' c cId mL ns = liftIO $ tableNgramsPatch c cId mL ns
getTableNgramsPatch' :: Connection -> CorpusId -> Maybe TabType -> Maybe ListId -> Handler NgramsIdPatchsBack
getTableNgramsPatch' c cId nType mL = liftIO $ getTableNgramsPatch c cId nType mL
query :: Text -> Handler Text
query s = pure s
......
......@@ -135,7 +135,7 @@ type Offset = Int
data Tree a = TreeN a [Tree a]
deriving (Show, Read, Eq, Generic, Ord)
instance ToJSON (Tree NodeTree) where
instance ToJSON a => ToJSON (Tree a) where
toJSON (TreeN node nodes) =
object ["node" A..= toJSON node, "children" A..= toJSON nodes]
......
......@@ -32,7 +32,7 @@ import Data.Tuple.Extra (both, second)
import qualified Data.Map as DM
import Gargantext.Core.Types (NodePoly(..), ListType(..), listId)
import Gargantext.Database.Bashql (runCmd', del)
import Gargantext.Database.Bashql (runCmd')--, del)
import Gargantext.Database.Ngrams (insertNgrams, Ngrams(..), NgramsT(..), NgramsIndexed(..), indexNgramsT, ngramsTypeId, NgramsType(..), text2ngrams)
import Gargantext.Database.Node (getRoot, mkRoot, mkCorpus, Cmd(..), mkList)
import Gargantext.Database.Node.Document.Add (add)
......@@ -68,8 +68,8 @@ flow fp cName = do
_ <- runCmd' $ insertToNodeNgrams indexedNgrams
-- List Flow
listId <- runCmd' $ listFlow masterUserId corpusId indexedNgrams
printDebug "list id:" listId
listId2 <- runCmd' $ listFlow masterUserId corpusId indexedNgrams
printDebug "list id:" listId2
printDebug "Docs IDs : " (length idsRepeat)
......
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