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
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
Christian Merten
haskell-gargantext
Commits
5f769583
Commit
5f769583
authored
Feb 18, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
[FIX] Annuaire / Team Node creation
parents
37477a45
e8b9202a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
144 additions
and
14 deletions
+144
-14
API.hs
src/Gargantext/API.hs
+16
-6
Annuaire.hs
src/Gargantext/API/Annuaire.hs
+113
-0
Node.hs
src/Gargantext/Database/Schema/Node.hs
+11
-6
Tree.hs
src/Gargantext/Database/Tree.hs
+1
-1
stack.yaml
stack.yaml
+3
-1
No files found.
src/Gargantext/API.hs
View file @
5f769583
...
@@ -94,6 +94,7 @@ import Gargantext.API.Ngrams (HasRepo(..), HasRepoSaver(..), saveRepo, TableNgra
...
@@ -94,6 +94,7 @@ import Gargantext.API.Ngrams (HasRepo(..), HasRepoSaver(..), saveRepo, TableNgra
import
Gargantext.API.Node
import
Gargantext.API.Node
import
Gargantext.API.Search
(
SearchPairsAPI
,
searchPairs
)
import
Gargantext.API.Search
(
SearchPairsAPI
,
searchPairs
)
import
Gargantext.API.Types
import
Gargantext.API.Types
import
qualified
Gargantext.API.Annuaire
as
Annuaire
import
qualified
Gargantext.API.Export
as
Export
import
qualified
Gargantext.API.Export
as
Export
import
qualified
Gargantext.API.Corpus.New
as
New
import
qualified
Gargantext.API.Corpus.New
as
New
import
Gargantext.Database.Types.Node
import
Gargantext.Database.Types.Node
...
@@ -304,6 +305,8 @@ type GargPrivateAPI' =
...
@@ -304,6 +305,8 @@ type GargPrivateAPI' =
-- :<|> New.Upload
-- :<|> New.Upload
:<|>
New
.
AddWithForm
:<|>
New
.
AddWithForm
:<|>
New
.
AddWithQuery
:<|>
New
.
AddWithQuery
:<|>
Annuaire
.
AddWithForm
-- :<|> New.AddWithFile
-- :<|> New.AddWithFile
-- :<|> "scraper" :> WithCallbacks ScraperAPI
-- :<|> "scraper" :> WithCallbacks ScraperAPI
-- :<|> "new" :> New.Api
-- :<|> "new" :> New.Api
...
@@ -390,8 +393,10 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
...
@@ -390,8 +393,10 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
-- TODO access
-- TODO access
-- :<|> addUpload
-- :<|> addUpload
-- :<|> (\corpus -> addWithQuery corpus :<|> addWithFile corpus)
-- :<|> (\corpus -> addWithQuery corpus :<|> addWithFile corpus)
:<|>
addWithForm
:<|>
addCorpusWithForm
:<|>
addWithQuery
:<|>
addCorpusWithQuery
:<|>
addAnnuaireWithForm
-- :<|> New.api uid -- TODO-SECURITY
-- :<|> New.api uid -- TODO-SECURITY
-- :<|> New.info uid -- TODO-SECURITY
-- :<|> New.info uid -- TODO-SECURITY
...
@@ -401,8 +406,8 @@ addUpload cId = (serveJobsAPI $ JobFunction (\i log -> New.addToCorpusJobFunctio
...
@@ -401,8 +406,8 @@ addUpload cId = (serveJobsAPI $ JobFunction (\i log -> New.addToCorpusJobFunctio
:<|> (serveJobsAPI $ JobFunction (\i log -> New.addToCorpusWithForm cid i (liftIO . log)))
:<|> (serveJobsAPI $ JobFunction (\i log -> New.addToCorpusWithForm cid i (liftIO . log)))
--}
--}
addWithQuery
::
GargServer
New
.
AddWithQuery
add
Corpus
WithQuery
::
GargServer
New
.
AddWithQuery
addWithQuery
cid
=
add
Corpus
WithQuery
cid
=
serveJobsAPI
$
serveJobsAPI
$
JobFunction
(
\
i
log
->
New
.
addToCorpusJobFunction
cid
i
(
liftIO
.
log
))
JobFunction
(
\
i
log
->
New
.
addToCorpusJobFunction
cid
i
(
liftIO
.
log
))
...
@@ -411,11 +416,16 @@ addWithFile cid i f =
...
@@ -411,11 +416,16 @@ addWithFile cid i f =
serveJobsAPI
$
serveJobsAPI
$
JobFunction
(
\
_i
log
->
New
.
addToCorpusWithFile
cid
i
f
(
liftIO
.
log
))
JobFunction
(
\
_i
log
->
New
.
addToCorpusWithFile
cid
i
f
(
liftIO
.
log
))
addWithForm
::
GargServer
New
.
AddWithForm
add
Corpus
WithForm
::
GargServer
New
.
AddWithForm
addWithForm
cid
=
add
Corpus
WithForm
cid
=
serveJobsAPI
$
serveJobsAPI
$
JobFunction
(
\
i
log
->
New
.
addToCorpusWithForm
cid
i
(
liftIO
.
log
))
JobFunction
(
\
i
log
->
New
.
addToCorpusWithForm
cid
i
(
liftIO
.
log
))
addAnnuaireWithForm
::
GargServer
Annuaire
.
AddWithForm
addAnnuaireWithForm
cid
=
serveJobsAPI
$
JobFunction
(
\
i
log
->
Annuaire
.
addToAnnuaireWithForm
cid
i
(
liftIO
.
log
))
serverStatic
::
Server
(
Get
'[
H
TML
]
Html
)
serverStatic
::
Server
(
Get
'[
H
TML
]
Html
)
serverStatic
=
$
(
do
serverStatic
=
$
(
do
let
path
=
"purescript-gargantext/dist/index.html"
let
path
=
"purescript-gargantext/dist/index.html"
...
...
src/Gargantext/API/Annuaire.hs
0 → 100644
View file @
5f769583
{-|
Module : Gargantext.API.Annuaire
Description : New annuaire API
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
module
Gargantext.API.Annuaire
where
import
Control.Lens
hiding
(
elements
)
import
Data.Aeson
import
Data.Swagger
import
Data.Text
(
Text
)
import
GHC.Generics
(
Generic
)
import
qualified
Gargantext.API.Corpus.New.File
as
NewFile
import
Gargantext.API.Orchestrator.Types
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core.Utils.Prefix
(
unPrefixSwagger
)
import
Gargantext.Database.Flow
(
FlowCmdM
)
-- flowAnnuaire
import
Gargantext.Database.Types.Node
(
AnnuaireId
)
import
Gargantext.Prelude
import
Servant
import
Servant.API.Flatten
(
Flat
)
import
Servant.Job.Core
import
Servant.Job.Types
import
Servant.Job.Utils
(
jsonOptions
)
import
Web.FormUrlEncoded
(
FromForm
)
type
Api
=
Summary
"New Annuaire endpoint"
:>
Post
'[
J
SON
]
AnnuaireId
------------------------------------------------------------------------
------------------------------------------------------------------------
data
WithForm
=
WithForm
{
_wf_filetype
::
!
NewFile
.
FileType
,
_wf_data
::
!
Text
,
_wf_lang
::
!
(
Maybe
Lang
)
}
deriving
(
Eq
,
Show
,
Generic
)
makeLenses
''
W
ithForm
instance
FromForm
WithForm
instance
FromJSON
WithForm
where
parseJSON
=
genericParseJSON
$
jsonOptions
"_wf_"
instance
ToSchema
WithForm
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"_wf_"
)
------------------------------------------------------------------------
type
AsyncJobs
event
ctI
input
output
=
Flat
(
AsyncJobsAPI'
'U
n
safe
'S
a
fe
ctI
'[
J
SON
]
Maybe
event
input
output
)
------------------------------------------------------------------------
type
AddWithForm
=
Summary
"Add with FormUrlEncoded to annuaire endpoint"
:>
"annuaire"
:>
Capture
"annuaire_id"
AnnuaireId
:>
"add"
:>
"form"
:>
"async"
:>
AsyncJobs
ScraperStatus
'[
F
ormUrlEncoded
]
WithForm
ScraperStatus
------------------------------------------------------------------------
addToAnnuaireWithForm
::
FlowCmdM
env
err
m
=>
AnnuaireId
->
WithForm
->
(
ScraperStatus
->
m
()
)
->
m
ScraperStatus
addToAnnuaireWithForm
_cid
(
WithForm
ft
_d
_l
)
logStatus
=
do
printDebug
"ft"
ft
-- let
-- parse = case ft of
-- CSV_HAL -> Parser.parseFormat Parser.CsvHal
-- CSV -> Parser.parseFormat Parser.CsvGargV3
-- WOS -> Parser.parseFormat Parser.WOS
-- PresseRIS -> Parser.parseFormat Parser.RisPresse
-- docs <- liftIO
-- $ splitEvery 500
-- <$> take 1000000
-- <$> parse (cs d)
logStatus
ScraperStatus
{
_scst_succeeded
=
Just
1
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
1
,
_scst_events
=
Just
[]
}
-- cid' <- flowCorpus "user1"
-- (Right [cid])
-- (Multi $ fromMaybe EN l)
-- (map (map toHyperdataDocument) docs)
-- printDebug "cid'" cid'
pure
ScraperStatus
{
_scst_succeeded
=
Just
2
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
0
,
_scst_events
=
Just
[]
}
src/Gargantext/Database/Schema/Node.hs
View file @
5f769583
...
@@ -620,15 +620,18 @@ childWith uId pId (Node' NodeContact txt v []) = node2table uId (Just pId) (Nod
...
@@ -620,15 +620,18 @@ childWith uId pId (Node' NodeContact txt v []) = node2table uId (Just pId) (Nod
childWith
_
_
(
Node'
_
_
_
_
)
=
panic
"This NodeType can not be a child"
childWith
_
_
(
Node'
_
_
_
_
)
=
panic
"This NodeType can not be a child"
-- =================================================================== --
------------------------------------------------------------------------
-- | TODO mk all others nodes
-- | TODO mk all others nodes
mkNodeWithParent
::
HasNodeError
err
=>
NodeType
->
Maybe
ParentId
->
UserId
->
Name
->
Cmd
err
[
NodeId
]
mkNodeWithParent
::
HasNodeError
err
=>
NodeType
->
Maybe
ParentId
->
UserId
->
Name
->
Cmd
err
[
NodeId
]
mkNodeWithParent
NodeUser
(
Just
_
)
_
_
=
nodeError
UserNoParent
mkNodeWithParent
NodeUser
(
Just
_
)
_
_
=
nodeError
UserNoParent
------------------------------------------------------------------------
mkNodeWithParent
NodeUser
Nothing
uId
name
=
mkNodeWithParent
NodeUser
Nothing
uId
name
=
insertNodesWithParentR
Nothing
[
node
NodeUser
name
hd
Nothing
uId
]
insertNodesWithParentR
Nothing
[
node
NodeUser
name
hd
Nothing
uId
]
where
where
hd
=
HyperdataUser
.
Just
.
pack
$
show
EN
hd
=
HyperdataUser
.
Just
.
pack
$
show
EN
mkNodeWithParent
_
Nothing
_
_
=
nodeError
HasParent
mkNodeWithParent
_
Nothing
_
_
=
nodeError
HasParent
------------------------------------------------------------------------
------------------------------------------------------------------------
mkNodeWithParent
NodeFolder
(
Just
i
)
uId
name
=
mkNodeWithParent
NodeFolder
(
Just
i
)
uId
name
=
insertNodesWithParentR
(
Just
i
)
[
node
NodeFolder
name
hd
Nothing
uId
]
insertNodesWithParentR
(
Just
i
)
[
node
NodeFolder
name
hd
Nothing
uId
]
...
@@ -654,18 +657,20 @@ mkNodeWithParent NodeTeam (Just i) uId _ =
...
@@ -654,18 +657,20 @@ mkNodeWithParent NodeTeam (Just i) uId _ =
insertNodesWithParentR
(
Just
i
)
[
node
NodeTeam
"Team"
hd
Nothing
uId
]
insertNodesWithParentR
(
Just
i
)
[
node
NodeTeam
"Team"
hd
Nothing
uId
]
where
where
hd
=
defaultFolder
hd
=
defaultFolder
------------------------------------------------------------------------
------------------------------------------------------------------------
mkNodeWithParent
NodeCorpus
(
Just
i
)
uId
name
=
mkNodeWithParent
NodeCorpus
(
Just
i
)
uId
name
=
insertNodesWithParentR
(
Just
i
)
[
node
NodeCorpus
name
hd
Nothing
uId
]
insertNodesWithParentR
(
Just
i
)
[
node
NodeCorpus
name
hd
Nothing
uId
]
where
where
hd
=
defaultCorpus
hd
=
defaultCorpus
mkNodeWithParent
NodeAnnuaire
(
Just
i
)
uId
name
=
insertNodesWithParentR
(
Just
i
)
[
node
NodeAnnuaire
name
hd
Nothing
uId
]
where
hd
=
defaultAnnuaire
mkNodeWithParent
_
_
_
_
=
nodeError
NotImplYet
mkNodeWithParent
_
_
_
_
=
nodeError
NotImplYet
------------------------------------------------------------------------
-- =================================================================== --
...
...
src/Gargantext/Database/Tree.hs
View file @
5f769583
...
@@ -108,7 +108,7 @@ dbTree rootId = map (\(nId, tId, pId, n) -> DbTreeNode nId tId pId n)
...
@@ -108,7 +108,7 @@ dbTree rootId = map (\(nId, tId, pId, n) -> DbTreeNode nId tId pId n)
FROM nodes AS c
FROM nodes AS c
INNER JOIN tree AS s ON c.parent_id = s.id
INNER JOIN tree AS s ON c.parent_id = s.id
WHERE c.typename IN (2,20,21,22,3,5,30,31,40,7,9,90,71)
--
WHERE c.typename IN (2,20,21,22,3,5,30,31,40,7,9,90,71)
)
)
SELECT * from tree;
SELECT * from tree;
|]
(
Only
rootId
)
|]
(
Only
rootId
)
...
...
stack.yaml
View file @
5f769583
...
@@ -7,7 +7,9 @@ packages:
...
@@ -7,7 +7,9 @@ packages:
docker
:
docker
:
enable
:
false
enable
:
false
repo
:
'
fpco/stack-build:lts-14.22-garg'
repo
:
'
fpco/stack-build:lts-14.6-garg'
run-args
:
-
'
--publish=8008:8008'
nix
:
nix
:
enable
:
false
enable
:
false
...
...
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