Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
195
Issues
195
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
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
gargantext
haskell-gargantext
Commits
1be75825
Commit
1be75825
authored
Dec 02, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[API][ROUTE] count tab result.
parent
4c3e98b6
Pipeline
#632
failed with stage
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
9 deletions
+42
-9
Table.hs
src/Gargantext/API/Table.hs
+41
-8
TextSearch.hs
src/Gargantext/Database/TextSearch.hs
+1
-1
No files found.
src/Gargantext/API/Table.hs
View file @
1be75825
...
...
@@ -57,11 +57,11 @@ import Test.QuickCheck (elements)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
------------------------------------------------------------------------
type
TableApi
=
Summary
" Table API"
:>
ReqBody
'[
J
SON
]
TableQuery
:>
Post
'[
J
SON
]
[
FacetDoc
]
:>
Post
'[
J
SON
]
TableResult
--{-
data
TableQuery
=
TableQuery
{
tq_offset
::
Int
,
tq_limit
::
Int
...
...
@@ -70,6 +70,18 @@ data TableQuery = TableQuery
,
tq_query
::
Text
}
deriving
(
Generic
)
data
TableResult
=
TableResult
{
tr_count
::
Int
,
tr_docs
::
[
FacetDoc
]
}
deriving
(
Generic
)
$
(
deriveJSON
(
unPrefix
"tr_"
)
''
T
ableResult
)
instance
ToSchema
TableResult
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"tr_"
)
instance
Arbitrary
TableResult
where
arbitrary
=
TableResult
<$>
arbitrary
<*>
arbitrary
$
(
deriveJSON
(
unPrefix
"tq_"
)
''
T
ableQuery
)
instance
ToSchema
TableQuery
where
...
...
@@ -79,17 +91,38 @@ instance Arbitrary TableQuery where
arbitrary
=
elements
[
TableQuery
0
10
DateAsc
Docs
"electrodes"
]
tableApi
::
NodeId
->
TableQuery
->
Cmd
err
[
FacetDoc
]
tableApi
::
NodeId
->
TableQuery
->
Cmd
err
TableResult
tableApi
cId
(
TableQuery
o
l
order
ft
""
)
=
getTable
cId
(
Just
ft
)
(
Just
o
)
(
Just
l
)
(
Just
order
)
tableApi
cId
(
TableQuery
o
l
order
ft
q
)
=
case
ft
of
Docs
->
searchInCorpus
cId
False
[
q
]
(
Just
o
)
(
Just
l
)
(
Just
order
)
Trash
->
searchInCorpus
cId
True
[
q
]
(
Just
o
)
(
Just
l
)
(
Just
order
)
Docs
->
searchInCorpus
'
cId
False
[
q
]
(
Just
o
)
(
Just
l
)
(
Just
order
)
Trash
->
searchInCorpus
'
cId
True
[
q
]
(
Just
o
)
(
Just
l
)
(
Just
order
)
x
->
panic
$
"not implemented in tableApi "
<>
(
cs
$
show
x
)
searchInCorpus'
::
CorpusId
->
Bool
->
[
Text
]
->
Maybe
Offset
->
Maybe
Limit
->
Maybe
OrderBy
->
Cmd
err
TableResult
searchInCorpus'
cId
t
q
o
l
order
=
do
docs
<-
searchInCorpus
cId
t
q
o
l
order
allDocs
<-
searchInCorpus
cId
t
q
Nothing
Nothing
Nothing
pure
(
TableResult
(
length
allDocs
)
docs
)
getTable
::
NodeId
->
Maybe
TabType
->
Maybe
Offset
->
Maybe
Limit
->
Maybe
OrderBy
->
Cmd
err
TableResult
getTable
cId
ft
o
l
order
=
do
docs
<-
getTable'
cId
ft
o
l
order
allDocs
<-
getTable'
cId
ft
Nothing
Nothing
Nothing
pure
(
TableResult
(
length
allDocs
)
docs
)
getTable'
::
NodeId
->
Maybe
TabType
->
Maybe
Offset
->
Maybe
Limit
->
Maybe
OrderBy
->
Cmd
err
[
FacetDoc
]
getTable
cId
ft
o
l
order
=
getTable
'
cId
ft
o
l
order
=
case
ft
of
(
Just
Docs
)
->
runViewDocuments
cId
False
o
l
order
(
Just
Trash
)
->
runViewDocuments
cId
True
o
l
order
...
...
src/Gargantext/Database/TextSearch.hs
View file @
1be75825
...
...
@@ -144,7 +144,7 @@ queryInCorpusWithContacts
->
Maybe
OrderBy
->
Text
->
O
.
Query
FacetPairedRead
queryInCorpusWithContacts
cId
lId
_
_
_
q
=
proc
()
->
do
queryInCorpusWithContacts
cId
_
lId
_
_
_
q
=
proc
()
->
do
(
n
,
(
nn
,
(
_nng
,
(
ngrams'
,
(
_
,
contacts
)))))
<-
joinInCorpusWithContacts
-<
()
restrict
-<
(
n
^.
ns_search
)
@@
(
pgTSQuery
$
unpack
q
)
restrict
-<
(
n
^.
ns_typename
)
.==
(
pgInt4
$
nodeTypeId
NodeDocument
)
...
...
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