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
424d20ee
Commit
424d20ee
authored
May 20, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SEARCH] and create corpus
parent
c3fc3946
Pipeline
#401
failed with stage
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
8 deletions
+50
-8
API.hs
src/Gargantext/API.hs
+4
-0
New.hs
src/Gargantext/API/Corpus/New.hs
+35
-6
Flow.hs
src/Gargantext/Database/Flow.hs
+11
-2
No files found.
src/Gargantext/API.hs
View file @
424d20ee
...
...
@@ -425,3 +425,7 @@ startGargantextMock port = do
application <- makeMockApp . MockEnv $ FireWall False
run port application
-}
src/Gargantext/API/Corpus/New.hs
View file @
424d20ee
...
...
@@ -18,20 +18,49 @@ New corpus means either:
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
module
Gargantext.API.Corpus.New
where
import
Servant
import
Gargantext.Prelude
import
Gargantext.API.Count
(
Query
(
..
))
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Swagger
import
Data.Text
(
Text
)
import
GHC.Generics
(
Generic
)
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
import
Gargantext.Database.Flow
(
flowCorpusSearchInDatabase
)
import
Gargantext.Database.Types.Node
(
CorpusId
)
--import Gargantext.Database.Flow (flowCorpusSearchInDatabase)
import
Gargantext.Prelude
import
Servant
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
import
Gargantext.Database.Flow
(
FlowCmdM
)
data
Query
=
Query
{
query_query
::
Text
,
query_corpus_id
::
Int
}
deriving
(
Eq
,
Show
,
Generic
)
deriveJSON
(
unPrefix
"query_"
)
''
Q
uery
instance
Arbitrary
Query
where
arbitrary
=
elements
[
Query
q
n
|
q
<-
[
"a"
,
"b"
]
,
n
<-
[
0
..
10
]
]
instance
ToSchema
Query
type
Api
=
Summary
"New Corpus endpoint"
:>
ReqBody
'[
J
SON
]
Query
:>
Post
'[
J
SON
]
CorpusId
api
::
Monad
m
=>
Query
->
m
CorpusId
api
_
=
pure
1
api
::
FlowCmdM
env
err
m
=>
Query
->
m
CorpusId
api
(
Query
q
_
)
=
do
cId
<-
flowCorpusSearchInDatabase
"user1"
EN
q
pure
cId
src/Gargantext/Database/Flow.hs
View file @
424d20ee
...
...
@@ -119,13 +119,22 @@ flowCorpusFile u n l la ff fp = do
flowCorpus
u
n
la
(
map
(
map
toHyperdataDocument
)
docs
)
-- TODO query with complex query
flowCorpusSearchInDatabase
::
FlowCmdM
env
ServantE
rr
m
flowCorpusSearchInDatabase
::
FlowCmdM
env
e
rr
m
=>
Username
->
Lang
->
Text
->
m
CorpusId
flowCorpusSearchInDatabase
u
la
q
=
do
(
_masterUserId
,
_masterRootId
,
cId
)
<-
getOrMkRootWithCorpus
userMaster
""
(
Nothing
::
Maybe
HyperdataCorpus
)
ids
<-
map
fst
<$>
searchInDatabase
cId
(
stemIt
q
)
flowCorpusUser
la
u
q
(
Nothing
::
Maybe
HyperdataCorpus
)
ids
flowCorpusSearchInDatabase'
::
FlowCmdM
env
ServantErr
m
=>
Username
->
Lang
->
Text
->
m
CorpusId
flowCorpusSearchInDatabase'
u
la
q
=
do
(
_masterUserId
,
_masterRootId
,
cId
)
<-
getOrMkRootWithCorpus
userMaster
""
(
Nothing
::
Maybe
HyperdataCorpus
)
ids
<-
map
fst
<$>
searchInDatabase
cId
(
stemIt
q
)
flowCorpusUser
la
u
q
(
Nothing
::
Maybe
HyperdataCorpus
)
ids
------------------------------------------------------------------------
flow
::
(
FlowCmdM
env
ServantErr
m
,
FlowCorpus
a
,
MkCorpus
c
)
...
...
@@ -139,7 +148,7 @@ flowCorpus :: (FlowCmdM env ServantErr m, FlowCorpus a)
flowCorpus
=
flow
(
Nothing
::
Maybe
HyperdataCorpus
)
flowCorpusUser
::
(
FlowCmdM
env
ServantE
rr
m
,
MkCorpus
c
)
flowCorpusUser
::
(
FlowCmdM
env
e
rr
m
,
MkCorpus
c
)
=>
Lang
->
Username
->
CorpusName
->
Maybe
c
->
[
NodeId
]
->
m
CorpusId
flowCorpusUser
l
userName
corpusName
ctype
ids
=
do
-- User Flow
...
...
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