Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Przemyslaw Kaminski
haskell-gargantext
Commits
82135cd7
Commit
82135cd7
authored
Apr 30, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] ApiNgramsTableDoc specs todo.
parent
37e49cce
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
68 deletions
+96
-68
API.hs
src/Gargantext/API.hs
+16
-11
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+77
-53
Node.hs
src/Gargantext/API/Node.hs
+3
-4
No files found.
src/Gargantext/API.hs
View file @
82135cd7
...
...
@@ -66,23 +66,23 @@ import Servant.Swagger.UI
import
Text.Blaze.Html
(
Html
)
--import Gargantext.API.Swagger
import
Gargantext.Prelude
import
Gargantext.Core.Types
(
HasInvalidError
(
..
))
import
Gargantext.API.FrontEnd
(
FrontEndAPI
,
frontEndServer
)
--import Gargantext.Database.Node.Contact (HyperdataContact)
import
Gargantext.API.Auth
(
AuthRequest
,
AuthResponse
,
auth
)
import
Gargantext.API.Ngrams
(
HasRepo
(
..
),
HasRepoSaver
(
..
),
saveRepo
)
import
Gargantext.API.Types
import
Gargantext.API.Count
(
CountAPI
,
count
,
Query
)
import
Gargantext.API.FrontEnd
(
FrontEndAPI
,
frontEndServer
)
import
Gargantext.API.Ngrams
(
HasRepo
(
..
),
HasRepoSaver
(
..
),
saveRepo
,
ApiNgramsTableDoc
,
apiNgramsTableDoc
)
import
Gargantext.API.Node
import
Gargantext.API.Search
(
SearchAPI
,
search
,
SearchQuery
)
import
Gargantext.API.Types
import
Gargantext.Core.Types
(
HasInvalidError
(
..
))
import
Gargantext.Database.Facet
import
Gargantext.Database.Schema.Node
(
HasNodeError
(
..
),
NodeError
)
--import Gargantext.Database.Node.Contact (HyperdataContact)
import
Gargantext.Database.Types.Node
import
Gargantext.Database.Utils
(
HasConnection
)
import
Gargantext.Database.Tree
(
HasTreeError
(
..
),
TreeError
)
import
Gargantext.Database.Types.Node
import
Gargantext.Database.Types.Node
(
NodeId
,
CorpusId
,
AnnuaireId
)
import
Gargantext.API.Count
(
CountAPI
,
count
,
Query
)
import
Gargantext.API.Search
(
SearchAPI
,
search
,
SearchQuery
)
import
Gargantext.Database.Facet
import
Gargantext.Database.Utils
(
HasConnection
)
import
Gargantext.Prelude
import
Gargantext.Viz.Graph.API
--import Gargantext.API.Orchestrator
...
...
@@ -248,6 +248,10 @@ type GargAPI' =
:<|>
"annuaire"
:>
Summary
"Annuaire endpoint"
:>
Capture
"id"
AnnuaireId
:>
NodeAPI
HyperdataAnnuaire
-- Document endpoint
:<|>
"document"
:>
Summary
"Document endpoint"
:>
Capture
"id"
DocId
:>
"ngrams"
:>
ApiNgramsTableDoc
-- Corpus endpoint
:<|>
"nodes"
:>
Summary
"Nodes endpoint"
:>
ReqBody
'[
J
SON
]
[
NodeId
]
:>
NodesAPI
...
...
@@ -310,6 +314,7 @@ serverGargAPI -- orchestrator
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataAny
)
fakeUserId
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataCorpus
)
fakeUserId
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataAnnuaire
)
fakeUserId
:<|>
apiNgramsTableDoc
:<|>
nodesAPI
:<|>
count
-- TODO: undefined
:<|>
search
...
...
src/Gargantext/API/Ngrams.hs
View file @
82135cd7
...
...
@@ -612,29 +612,6 @@ ngramsIdPatch = fromList $ catMaybes $ reverse [ replace (1::NgramsId) (Just $ n
------------------------------------------------------------------------
------------------------------------------------------------------------
-- TODO: find a better place for this Gargantext.API.{Common|Prelude|Core} ?
type
QueryParamR
=
QueryParam'
'[
R
equired
,
Strict
]
type
TableNgramsApiGet
=
Summary
" Table Ngrams API Get"
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParamR
"list"
ListId
:>
QueryParamR
"limit"
Limit
:>
QueryParam
"offset"
Offset
:>
QueryParam
"listType"
ListType
:>
QueryParam
"minTermSize"
Int
:>
QueryParam
"maxTermSize"
Int
:>
QueryParam
"search"
Text
:>
Get
'[
J
SON
]
(
Versioned
NgramsTable
)
type
TableNgramsApi
=
Summary
" Table Ngrams API Change"
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParamR
"list"
ListId
:>
ReqBody
'[
J
SON
]
(
Versioned
NgramsTablePatch
)
:>
Put
'[
J
SON
]
(
Versioned
NgramsTablePatch
)
{-
-- TODO: Replace.old is ignored which means that if the current list
-- `GraphTerm` and that the patch is `Replace CandidateTerm StopTerm` then
...
...
@@ -810,11 +787,11 @@ putListNgrams listId ngramsType nes = do
-- Apply the given patch to the DB and returns the patch to be applied on the
-- client.
tableNgramsP
atch
::
(
HasInvalidError
err
,
RepoCmdM
env
err
m
)
tableNgramsP
ut
::
(
HasInvalidError
err
,
RepoCmdM
env
err
m
)
=>
CorpusId
->
TabType
->
ListId
->
Versioned
NgramsTablePatch
->
m
(
Versioned
NgramsTablePatch
)
tableNgramsP
atch
_corpusId
tabType
listId
(
Versioned
p_version
p_table
)
tableNgramsP
ut
_corpusId
tabType
listId
(
Versioned
p_version
p_table
)
|
p_table
==
mempty
=
do
let
ngramsType
=
ngramsTypeFromTabType
tabType
...
...
@@ -889,34 +866,6 @@ type MaxSize = Int
getTableNgramsCorpus
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnection
env
)
=>
NodeId
->
TabType
->
ListId
->
Limit
->
Maybe
Offset
->
Maybe
ListType
->
Maybe
MinSize
->
Maybe
MaxSize
->
Maybe
Text
-- full text search
->
m
(
Versioned
NgramsTable
)
getTableNgramsCorpus
nId
tabType
listId
limit_
offset
listType
minSize
maxSize
mt
=
getTableNgrams
nId
tabType
listId
limit_
offset
listType
minSize
maxSize
searchQuery
where
searchQuery
=
maybe
(
const
True
)
isInfixOf
mt
-- | Text search is deactivated for now for ngrams by doc only
getTableNgramsDoc
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnection
env
)
=>
CorpusId
->
DocId
->
TabType
->
ListId
->
Limit
->
Maybe
Offset
->
Maybe
ListType
->
Maybe
MinSize
->
Maybe
MaxSize
->
Maybe
Text
-- full text search
->
m
(
Versioned
NgramsTable
)
getTableNgramsDoc
cId
dId
tabType
listId
limit_
offset
listType
minSize
maxSize
_mt
=
do
ns
<-
selectNodesWithUsername
NodeList
userMaster
let
ngramsType
=
ngramsTypeFromTabType
tabType
ngs
<-
selectNgramsByDoc
(
ns
<>
[
cId
])
dId
ngramsType
let
searchQuery
=
flip
S
.
member
(
S
.
fromList
ngs
)
getTableNgrams
cId
tabType
listId
limit_
offset
listType
minSize
maxSize
searchQuery
getTableNgrams
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnection
env
)
=>
NodeId
->
TabType
->
ListId
->
Limit
->
Maybe
Offset
...
...
@@ -968,3 +917,78 @@ getTableNgrams nId tabType listId limit_ offset
pure
$
table
&
v_data
.
_NgramsTable
.
each
%~
setOcc
-- APIs
-- TODO: find a better place for the code above, All APIs stay here
type
QueryParamR
=
QueryParam'
'[
R
equired
,
Strict
]
type
TableNgramsApiGet
=
Summary
" Table Ngrams API Get"
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParamR
"list"
ListId
:>
QueryParamR
"limit"
Limit
:>
QueryParam
"offset"
Offset
:>
QueryParam
"listType"
ListType
:>
QueryParam
"minTermSize"
Int
:>
QueryParam
"maxTermSize"
Int
:>
QueryParam
"search"
Text
:>
Get
'[
J
SON
]
(
Versioned
NgramsTable
)
type
TableNgramsApiPut
=
Summary
" Table Ngrams API Change"
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParamR
"list"
ListId
:>
ReqBody
'[
J
SON
]
(
Versioned
NgramsTablePatch
)
:>
Put
'[
J
SON
]
(
Versioned
NgramsTablePatch
)
getTableNgramsCorpus
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnection
env
)
=>
NodeId
->
TabType
->
ListId
->
Limit
->
Maybe
Offset
->
Maybe
ListType
->
Maybe
MinSize
->
Maybe
MaxSize
->
Maybe
Text
-- full text search
->
m
(
Versioned
NgramsTable
)
getTableNgramsCorpus
nId
tabType
listId
limit_
offset
listType
minSize
maxSize
mt
=
getTableNgrams
nId
tabType
listId
limit_
offset
listType
minSize
maxSize
searchQuery
where
searchQuery
=
maybe
(
const
True
)
isInfixOf
mt
-- | Text search is deactivated for now for ngrams by doc only
getTableNgramsDoc
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnection
env
)
=>
DocId
->
TabType
->
ListId
->
Limit
->
Maybe
Offset
->
Maybe
ListType
->
Maybe
MinSize
->
Maybe
MaxSize
->
Maybe
Text
-- full text search
->
m
(
Versioned
NgramsTable
)
getTableNgramsDoc
dId
tabType
listId
limit_
offset
listType
minSize
maxSize
_mt
=
do
ns
<-
selectNodesWithUsername
NodeList
userMaster
let
ngramsType
=
ngramsTypeFromTabType
tabType
ngs
<-
selectNgramsByDoc
(
ns
<>
[
listId
])
dId
ngramsType
let
searchQuery
=
flip
S
.
member
(
S
.
fromList
ngs
)
getTableNgrams
dId
tabType
listId
limit_
offset
listType
minSize
maxSize
searchQuery
--{-
-- TODO Doc Table Ngrams API
type
ApiNgramsTableDoc
=
TableNgramsApiGet
-- :<|> TableNgramsApiPut
-- :<|> TableNgramsApiPost
apiNgramsTableDoc
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnection
env
)
=>
DocId
->
TabType
->
ListId
->
Limit
->
Maybe
Offset
->
Maybe
ListType
->
Maybe
MinSize
->
Maybe
MaxSize
->
Maybe
Text
-- full text search
->
m
(
Versioned
NgramsTable
)
{- TODO
--apiDocNgramsTable :: ApiDocNgramsTable
--apiDocNgramsTable :: ApiDocNgramsTable
--apiDocNgramsTable = getTableNgramsDoc
:<|> tableNgramsPut
:<|> tableNgramsPost
--}
apiNgramsTableDoc
=
getTableNgramsDoc
src/Gargantext/API/Node.hs
View file @
82135cd7
...
...
@@ -45,7 +45,7 @@ import Data.Text (Text())
import
Data.Time
(
UTCTime
)
import
GHC.Generics
(
Generic
)
import
Gargantext.API.Metrics
import
Gargantext.API.Ngrams
(
TabType
(
..
),
TableNgramsApi
,
TableNgramsApiGet
,
tableNgramsPatch
,
getTableNgramsCorpus
,
QueryParamR
)
import
Gargantext.API.Ngrams
(
TabType
(
..
),
TableNgramsApi
Put
,
TableNgramsApiGet
,
tableNgramsPut
,
getTableNgramsCorpus
,
QueryParamR
)
import
Gargantext.API.Search
(
SearchAPI
,
searchIn
,
SearchInQuery
)
import
Gargantext.API.Types
import
Gargantext.Core.Types
(
Offset
,
Limit
)
...
...
@@ -122,10 +122,9 @@ type NodeAPI a = Get '[JSON] (Node a)
-- TODO gather it
:<|>
"table"
:>
TableApi
:<|>
"list"
:>
TableNgramsApi
:<|>
"listGet"
:>
TableNgramsApiGet
:<|>
"list"
:>
TableNgramsApiPut
:<|>
"pairing"
:>
PairingApi
-- :<|> "document" :> Capture "docId" :> "list" :> TableNgramsApiGet
:<|>
"favorites"
:>
FavApi
:<|>
"documents"
:>
DocsApi
...
...
@@ -171,8 +170,8 @@ nodeAPI p uId id
-- TODO gather it
:<|>
getTable
id
:<|>
tableNgramsPatch
id
:<|>
getTableNgramsCorpus
id
:<|>
tableNgramsPut
id
:<|>
getPairing
id
-- :<|> getTableNgramsDoc id
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment