Commit 5e9336e4 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[API][PAIRING] adding route to pair a corpus with an annuaire (need to note this in db)

parent 5a3ebd2c
...@@ -57,6 +57,7 @@ import Gargantext.API.Types ...@@ -57,6 +57,7 @@ import Gargantext.API.Types
import Gargantext.Core.Types (NodeTableResult) import Gargantext.Core.Types (NodeTableResult)
import Gargantext.Core.Types.Main (Tree, NodeTree, ListType) import Gargantext.Core.Types.Main (Tree, NodeTree, ListType)
import Gargantext.Database.Config (nodeTypeId) import Gargantext.Database.Config (nodeTypeId)
import Gargantext.Database.Flow.Pairing (pairing)
import Gargantext.Database.Facet (FacetDoc, OrderBy(..)) import Gargantext.Database.Facet (FacetDoc, OrderBy(..))
import Gargantext.Database.Node.Children (getChildren) import Gargantext.Database.Node.Children (getChildren)
import Gargantext.Database.Schema.Node ( getNodesWithParentId, getNodeWith, getNode, deleteNode, deleteNodes, mkNodeWithParent, JSONB, HasNodeError(..)) import Gargantext.Database.Schema.Node ( getNodesWithParentId, getNodeWith, getNode, deleteNode, deleteNodes, mkNodeWithParent, JSONB, HasNodeError(..))
...@@ -128,10 +129,11 @@ type NodeAPI a = Get '[JSON] (Node a) ...@@ -128,10 +129,11 @@ type NodeAPI a = Get '[JSON] (Node a)
-- TODO gather it -- TODO gather it
:<|> "table" :> TableApi :<|> "table" :> TableApi
:<|> "ngrams" :> TableNgramsApi :<|> "ngrams" :> TableNgramsApi
:<|> "pairing" :> PairingApi
:<|> "category" :> CatApi :<|> "category" :> CatApi
:<|> "search" :> SearchDocsAPI :<|> "search" :> SearchDocsAPI
-- Pairing utilities
:<|> "pairing" :> PairingApi
:<|> "searchPair" :> SearchPairsAPI :<|> "searchPair" :> SearchPairsAPI
-- VIZ -- VIZ
...@@ -189,12 +191,12 @@ nodeAPI p uId id = withAccess (Proxy :: Proxy (NodeAPI a)) Proxy uId (PathNode i ...@@ -189,12 +191,12 @@ nodeAPI p uId id = withAccess (Proxy :: Proxy (NodeAPI a)) Proxy uId (PathNode i
-- TODO gather it -- TODO gather it
:<|> tableApi id :<|> tableApi id
:<|> apiNgramsTableCorpus id :<|> apiNgramsTableCorpus id
:<|> getPairing id
-- :<|> getTableNgramsDoc id
:<|> catApi id :<|> catApi id
:<|> searchDocs id :<|> searchDocs id
-- Pairing Tools
:<|> getPair id
:<|> searchPairs id :<|> searchPairs id
:<|> getScatter id :<|> getScatter id
...@@ -256,6 +258,7 @@ catApi = putCat ...@@ -256,6 +258,7 @@ catApi = putCat
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- TODO adapt FacetDoc -> ListDoc (and add type of document as column) -- TODO adapt FacetDoc -> ListDoc (and add type of document as column)
-- Pairing utilities to move elsewhere
type PairingApi = Summary " Pairing API" type PairingApi = Summary " Pairing API"
:> QueryParam "view" TabType :> QueryParam "view" TabType
-- TODO change TabType -> DocType (CorpusId for pairing) -- TODO change TabType -> DocType (CorpusId for pairing)
...@@ -264,6 +267,18 @@ type PairingApi = Summary " Pairing API" ...@@ -264,6 +267,18 @@ type PairingApi = Summary " Pairing API"
:> QueryParam "order" OrderBy :> QueryParam "order" OrderBy
:> Get '[JSON] [FacetDoc] :> Get '[JSON] [FacetDoc]
----------
type PairWith = Summary "Pair a Corpus with an Annuaire"
:> "annuaire" :> Capture "annuaire_id" AnnuaireId
:> "list" :> Capture "list_id" ListId
:> Post '[JSON] Int
pairWith :: CorpusId -> GargServer PairWith
pairWith cId aId lId = do
r <- pairing cId aId lId
pure r
------------------------------------------------------------------------ ------------------------------------------------------------------------
type ChartApi = Summary " Chart API" type ChartApi = Summary " Chart API"
:> QueryParam "from" UTCTime :> QueryParam "from" UTCTime
......
...@@ -121,14 +121,13 @@ getTable' cId ft o l order = ...@@ -121,14 +121,13 @@ getTable' cId ft o l order =
(Just MoreTrash) -> moreLike cId o l order IsTrash (Just MoreTrash) -> moreLike cId o l order IsTrash
x -> panic $ "not implemented in getTable: " <> (cs $ show x) x -> panic $ "not implemented in getTable: " <> (cs $ show x)
--{-
getPairing :: ContactId -> Maybe TabType getPair :: ContactId -> Maybe TabType
-> Maybe Offset -> Maybe Limit -> Maybe Offset -> Maybe Limit
-> Maybe OrderBy -> Cmd err [FacetDoc] -> Maybe OrderBy -> Cmd err [FacetDoc]
getPairing cId ft o l order = getPair cId ft o l order =
case ft of case ft of
(Just Docs) -> runViewAuthorsDoc cId False o l order (Just Docs) -> runViewAuthorsDoc cId False o l order
(Just Trash) -> runViewAuthorsDoc cId True o l order (Just Trash) -> runViewAuthorsDoc cId True o l order
_ -> panic $ "not implemented: get Pairing" <> (cs $ show ft) _ -> panic $ "not implemented: get Pairing" <> (cs $ show ft)
--}
...@@ -52,11 +52,11 @@ pairing' = undefined ...@@ -52,11 +52,11 @@ pairing' = undefined
-} -}
-- | TODO : add paring policy as parameter -- | TODO : add paring policy as parameter
pairing :: AnnuaireId -- (AnnuaireId, ListId) -- Pair (Either CorpusId AnnuaireId) ListId pairing :: CorpusId -- (CorpusId, ListId) -- Pair (Either CorpusId AnnuaireId) ListId
-> CorpusId -- (CorpusId, ListId) -- Pair (Either CorpusId AnnuaireId) ListId -> AnnuaireId -- (AnnuaireId, ListId) -- Pair (Either CorpusId AnnuaireId) ListId
-> ListId -> ListId
-> Cmd err Int -> Cmd err Int
pairing aId cId lId = do pairing cId aId lId = do
contacts' <- getAllContacts aId contacts' <- getAllContacts aId
let contactsMap = pairingPolicyToMap toLower let contactsMap = pairingPolicyToMap toLower
$ toMaps extractNgramsT (tr_docs contacts') $ toMaps extractNgramsT (tr_docs contacts')
......
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