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
1aa7eefa
Commit
1aa7eefa
authored
Jul 27, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into dev-doc-annotation-issue
parents
44a2d2ad
b3ad95a1
Changes
44
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
44 changed files
with
870 additions
and
380 deletions
+870
-380
schema.sql
devops/postgres/schema.sql
+2
-2
gargantext.ini_toModify
gargantext.ini_toModify
+11
-1
package.yaml
package.yaml
+10
-0
HashedResponse.hs
src/Gargantext/API/HashedResponse.hs
+1
-1
List.hs
src/Gargantext/API/Ngrams/List.hs
+0
-3
Tools.hs
src/Gargantext/API/Ngrams/Tools.hs
+7
-4
Contact.hs
src/Gargantext/API/Node/Contact.hs
+120
-0
Annuaire.hs
src/Gargantext/API/Node/Corpus/Annuaire.hs
+0
-19
Export.hs
src/Gargantext/API/Node/Corpus/Export.hs
+9
-9
New.hs
src/Gargantext/API/Node/Corpus/New.hs
+2
-2
File.hs
src/Gargantext/API/Node/Corpus/New/File.hs
+1
-1
Update.hs
src/Gargantext/API/Node/Update.hs
+4
-4
Routes.hs
src/Gargantext/API/Routes.hs
+3
-7
Search.hs
src/Gargantext/API/Search.hs
+5
-5
Hash.hs
src/Gargantext/Core/Crypto/Hash.hs
+54
-0
Pass.hs
src/Gargantext/Core/Crypto/Pass.hs
+111
-0
Mail.hs
src/Gargantext/Core/Mail.hs
+37
-0
Database.hs
src/Gargantext/Database.hs
+30
-2
Flow.hs
src/Gargantext/Database/Action/Flow.hs
+3
-4
Pairing.hs
src/Gargantext/Database/Action/Flow/Pairing.hs
+153
-106
Learn.hs
src/Gargantext/Database/Action/Learn.hs
+2
-2
Node.hs
src/Gargantext/Database/Action/Node.hs
+1
-1
Search.hs
src/Gargantext/Database/Action/Search.hs
+108
-107
Share.hs
src/Gargantext/Database/Action/Share.hs
+5
-4
Config.hs
src/Gargantext/Database/Admin/Config.hs
+8
-8
Contact.hs
src/Gargantext/Database/Admin/Types/Hyperdata/Contact.hs
+28
-5
Prelude.hs
src/Gargantext/Database/Admin/Types/Hyperdata/Prelude.hs
+1
-1
Node.hs
src/Gargantext/Database/Admin/Types/Node.hs
+7
-1
Prelude.hs
src/Gargantext/Database/Prelude.hs
+0
-1
Facet.hs
src/Gargantext/Database/Query/Facet.hs
+30
-11
Join.hs
src/Gargantext/Database/Query/Join.hs
+24
-9
Prelude.hs
src/Gargantext/Database/Query/Prelude.hs
+25
-0
Ngrams.hs
src/Gargantext/Database/Query/Table/Ngrams.hs
+1
-1
Node.hs
src/Gargantext/Database/Query/Table/Node.hs
+17
-0
Children.hs
src/Gargantext/Database/Query/Table/Node/Children.hs
+3
-0
Insert.hs
src/Gargantext/Database/Query/Table/Node/Document/Insert.hs
+1
-1
NodeNode.hs
src/Gargantext/Database/Query/Table/NodeNode.hs
+29
-3
Ngrams.hs
src/Gargantext/Database/Schema/Ngrams.hs
+3
-3
Node.hs
src/Gargantext/Database/Schema/Node.hs
+0
-2
NodeNode.hs
src/Gargantext/Database/Schema/NodeNode.hs
+9
-9
Prelude.hs
src/Gargantext/Database/Schema/Prelude.hs
+1
-1
Prelude.hs
src/Gargantext/Prelude.hs
+0
-3
Utils.hs
src/Gargantext/Prelude/Utils.hs
+2
-35
stack.yaml
stack.yaml
+2
-2
No files found.
devops/postgres/schema.sql
View file @
1aa7eefa
...
@@ -92,10 +92,11 @@ CREATE TABLE public.nodes_nodes (
...
@@ -92,10 +92,11 @@ CREATE TABLE public.nodes_nodes (
node2_id
INTEGER
NOT
NULL
REFERENCES
public
.
nodes
(
id
)
ON
DELETE
CASCADE
,
node2_id
INTEGER
NOT
NULL
REFERENCES
public
.
nodes
(
id
)
ON
DELETE
CASCADE
,
score
REAL
,
score
REAL
,
category
INTEGER
,
category
INTEGER
,
PRIMARY
KEY
(
node1_id
,
node2_id
)
PRIMARY
KEY
(
node1_id
,
node2_id
)
);
);
ALTER
TABLE
public
.
nodes_nodes
OWNER
TO
gargantua
;
ALTER
TABLE
public
.
nodes_nodes
OWNER
TO
gargantua
;
---------------------------------------------------------------
---------------------------------------------------------------
CREATE
TABLE
public
.
node_node_ngrams
(
CREATE
TABLE
public
.
node_node_ngrams
(
node1_id
INTEGER
NOT
NULL
REFERENCES
public
.
nodes
(
id
)
ON
DELETE
CASCADE
,
node1_id
INTEGER
NOT
NULL
REFERENCES
public
.
nodes
(
id
)
ON
DELETE
CASCADE
,
...
@@ -107,7 +108,6 @@ PRIMARY KEY (node1_id, node2_id, ngrams_id, ngrams_type)
...
@@ -107,7 +108,6 @@ PRIMARY KEY (node1_id, node2_id, ngrams_id, ngrams_type)
);
);
ALTER
TABLE
public
.
node_node_ngrams
OWNER
TO
gargantua
;
ALTER
TABLE
public
.
node_node_ngrams
OWNER
TO
gargantua
;
CREATE
TABLE
public
.
node_node_ngrams2
(
CREATE
TABLE
public
.
node_node_ngrams2
(
node_id
INTEGER
NOT
NULL
REFERENCES
public
.
nodes
(
id
)
ON
DELETE
CASCADE
,
node_id
INTEGER
NOT
NULL
REFERENCES
public
.
nodes
(
id
)
ON
DELETE
CASCADE
,
nodengrams_id
INTEGER
NOT
NULL
REFERENCES
public
.
node_ngrams
(
id
)
ON
DELETE
CASCADE
,
nodengrams_id
INTEGER
NOT
NULL
REFERENCES
public
.
node_ngrams
(
id
)
ON
DELETE
CASCADE
,
...
...
gargantext.ini_toModify
View file @
1aa7eefa
...
@@ -4,9 +4,18 @@ MASTER_USER = gargantua
...
@@ -4,9 +4,18 @@ MASTER_USER = gargantua
# SECURITY WARNING: keep the secret key used in production secret!
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = PASSWORD_TO_CHANGE
SECRET_KEY = PASSWORD_TO_CHANGE
# Frames
FRAME_WRITE_URL = URL_TO_CHANGE
FRAME_WRITE_URL = URL_TO_CHANGE
FRAME_CALC_URL = URL_TO_CHANGE
FRAME_CALC_URL = URL_TO_CHANGE
[network]
# Emails From address (sent by smtp)
MAIL = username@gargantext.org
HOST = localhost
# if remote smtp host
# HOST_USER = user
# HOST_password = password
[database]
[database]
# PostgreSQL access
# PostgreSQL access
DB_HOST = 127.0.0.1
DB_HOST = 127.0.0.1
...
@@ -14,7 +23,8 @@ DB_PORT = 5432
...
@@ -14,7 +23,8 @@ DB_PORT = 5432
DB_NAME = gargandbV5
DB_NAME = gargandbV5
DB_USER = gargantua
DB_USER = gargantua
DB_PASS = PASSWORD_TO_CHANGE
DB_PASS = PASSWORD_TO_CHANGE
# Logs
[logs]
LOG_FILE = /var/log/gargantext/backend.log
LOG_FILE = /var/log/gargantext/backend.log
LOG_LEVEL = DEBUG
LOG_LEVEL = DEBUG
LOG_FORMATTER = verbose
LOG_FORMATTER = verbose
package.yaml
View file @
1aa7eefa
...
@@ -208,6 +208,16 @@ library:
...
@@ -208,6 +208,16 @@ library:
-
servant-xml
-
servant-xml
-
simple-reflect
-
simple-reflect
-
singletons
# (IGraph)
-
singletons
# (IGraph)
# for mail
-
smtp-mail
-
mime-mail
# for password generation
-
cprng-aes
-
binary
-
crypto-random
-
split
-
split
-
stemmer
-
stemmer
-
string-conversions
-
string-conversions
...
...
src/Gargantext/API/HashedResponse.hs
View file @
1aa7eefa
...
@@ -5,7 +5,7 @@ import Data.Swagger
...
@@ -5,7 +5,7 @@ import Data.Swagger
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
qualified
Gargantext.
Prelude.Utils
as
Crypto
(
hash
)
import
qualified
Gargantext.
Core.Crypto.Hash
as
Crypto
(
hash
)
import
GHC.Generics
(
Generic
)
import
GHC.Generics
(
Generic
)
data
HashedResponse
a
=
HashedResponse
{
hash
::
Text
,
value
::
a
}
data
HashedResponse
a
=
HashedResponse
{
hash
::
Text
,
value
::
a
}
...
...
src/Gargantext/API/Ngrams/List.hs
View file @
1aa7eefa
...
@@ -55,7 +55,6 @@ instance ToJSON a => MimeRender HTML a where
...
@@ -55,7 +55,6 @@ instance ToJSON a => MimeRender HTML a where
mimeRender
_
=
encode
mimeRender
_
=
encode
------------------------------------------------------------------------
------------------------------------------------------------------------
get
::
RepoCmdM
env
err
m
=>
get
::
RepoCmdM
env
err
m
=>
ListId
->
m
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
NgramsList
)
ListId
->
m
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
NgramsList
)
get
lId
=
do
get
lId
=
do
...
@@ -74,7 +73,6 @@ get' lId = fromList
...
@@ -74,7 +73,6 @@ get' lId = fromList
<$>
mapM
(
getNgramsTableMap
lId
)
ngramsTypes
<$>
mapM
(
getNgramsTableMap
lId
)
ngramsTypes
------------------------------------------------------------------------
------------------------------------------------------------------------
-- TODO : purge list
-- TODO : purge list
post
::
FlowCmdM
env
err
m
post
::
FlowCmdM
env
err
m
=>
ListId
=>
ListId
...
@@ -88,7 +86,6 @@ post l m = do
...
@@ -88,7 +86,6 @@ post l m = do
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
type
PostAPI
=
Summary
"Update List"
type
PostAPI
=
Summary
"Update List"
:>
"add"
:>
"add"
:>
"form"
:>
"form"
...
...
src/Gargantext/API/Ngrams/Tools.hs
View file @
1aa7eefa
...
@@ -67,15 +67,18 @@ getTermsWith f ls ngt lt = Map.fromListWith (<>)
...
@@ -67,15 +67,18 @@ getTermsWith f ls ngt lt = Map.fromListWith (<>)
Nothing
->
(
f''
t
,
[]
)
Nothing
->
(
f''
t
,
[]
)
Just
r
->
(
f''
r
,
map
f''
[
t
])
Just
r
->
(
f''
r
,
map
f''
[
t
])
mapTermListRoot
::
[
ListId
]
->
NgramsType
mapTermListRoot
::
[
ListId
]
->
NgramsRepo
->
Map
Text
(
ListType
,
(
Maybe
Text
))
->
NgramsType
->
NgramsRepo
->
Map
Text
(
ListType
,
(
Maybe
Text
))
mapTermListRoot
nodeIds
ngramsType
repo
=
mapTermListRoot
nodeIds
ngramsType
repo
=
Map
.
fromList
[
(
t
,
(
_nre_list
nre
,
_nre_root
nre
))
Map
.
fromList
[
(
t
,
(
_nre_list
nre
,
_nre_root
nre
))
|
(
t
,
nre
)
<-
Map
.
toList
ngrams
|
(
t
,
nre
)
<-
Map
.
toList
ngrams
]
]
where
ngrams
=
listNgramsFromRepo
nodeIds
ngramsType
repo
where
ngrams
=
listNgramsFromRepo
nodeIds
ngramsType
repo
filterListWithRoot
::
ListType
->
Map
Text
(
ListType
,
Maybe
Text
)
filterListWithRoot
::
ListType
->
Map
Text
(
ListType
,
Maybe
Text
)
->
Map
Text
(
Maybe
RootTerm
)
->
Map
Text
(
Maybe
RootTerm
)
filterListWithRoot
lt
m
=
Map
.
fromList
filterListWithRoot
lt
m
=
Map
.
fromList
$
map
(
\
(
t
,(
_
,
r
))
->
(
t
,
r
))
$
map
(
\
(
t
,(
_
,
r
))
->
(
t
,
r
))
...
...
src/Gargantext/API/Node/Contact.hs
0 → 100644
View file @
1aa7eefa
{-|
Module : Gargantext.API.Node.Contact
Description :
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module
Gargantext.API.Node.Contact
where
import
Data.Aeson
import
Data.Either
(
Either
(
Right
))
import
Data.Maybe
(
Maybe
(
..
))
import
Data.Swagger
import
Data.Text
(
Text
)
import
GHC.Generics
(
Generic
)
import
Gargantext.API.Admin.Orchestrator.Types
(
JobLog
(
..
))
import
Gargantext.API.Admin.Settings
(
HasSettings
)
import
Gargantext.API.Node
import
Gargantext.API.Node.Corpus.New
(
AsyncJobs
)
import
Gargantext.API.Prelude
(
GargServer
,
simuLogs
)
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Database.Action.Flow
(
flow
)
import
Gargantext.Database.Action.Flow.Types
(
FlowCmdM
)
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataAnnuaire
(
..
),
HyperdataContact
)
import
Gargantext.Database.Admin.Types.Hyperdata.Contact
(
hyperdataContact
)
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Prelude
((
$
),
liftBase
,
(
.
),
printDebug
,
pure
)
import
Gargantext.Text.Terms
(
TermType
(
..
))
import
Servant
import
Servant.Job.Async
(
JobFunction
(
..
),
serveJobsAPI
)
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
------------------------------------------------------------------------
type
API
=
"contact"
:>
Summary
"Contact endpoint"
:>
API_Async
:<|>
Capture
"contact_id"
NodeId
:>
NodeNodeAPI
HyperdataContact
api
::
UserId
->
CorpusId
->
GargServer
API
api
uid
cid
=
(
api_async
(
RootId
(
NodeId
uid
))
cid
)
:<|>
(
nodeNodeAPI
(
Proxy
::
Proxy
HyperdataContact
)
uid
cid
)
type
API_Async
=
AsyncJobs
JobLog
'[
J
SON
]
AddContactParams
JobLog
------------------------------------------------------------------------
data
AddContactParams
=
AddContactParams
{
firstname
::
!
Text
,
lastname
::
!
Text
}
|
AddContactParamsAdvanced
{
firstname
::
!
Text
,
lastname
::
!
Text
-- TODO add others fields
}
deriving
(
Generic
)
----------------------------------------------------------------------
api_async
::
User
->
NodeId
->
GargServer
API_Async
api_async
u
nId
=
serveJobsAPI
$
JobFunction
(
\
p
log
->
let
log'
x
=
do
printDebug
"addContact"
x
liftBase
$
log
x
in
addContact
u
nId
p
(
liftBase
.
log'
)
)
addContact
::
(
HasSettings
env
,
FlowCmdM
env
err
m
)
=>
User
->
NodeId
->
AddContactParams
->
(
JobLog
->
m
()
)
->
m
JobLog
addContact
u
nId
(
AddContactParams
fn
ln
)
logStatus
=
do
logStatus
JobLog
{
_scst_succeeded
=
Just
1
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
1
,
_scst_events
=
Just
[]
}
_
<-
flow
(
Nothing
::
Maybe
HyperdataAnnuaire
)
u
(
Right
[
nId
])
(
Multi
EN
)
[[
hyperdataContact
fn
ln
]]
pure
JobLog
{
_scst_succeeded
=
Just
2
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
0
,
_scst_events
=
Just
[]
}
addContact
_uId
_nId
_p
logStatus
=
do
simuLogs
logStatus
10
------------------------------------------------------------------------
-- TODO unPrefix "pn_" FromJSON, ToJSON, ToSchema, adapt frontend.
instance
FromJSON
AddContactParams
where
parseJSON
=
genericParseJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
})
instance
ToJSON
AddContactParams
where
toJSON
=
genericToJSON
(
defaultOptions
{
sumEncoding
=
ObjectWithSingleField
})
instance
ToSchema
AddContactParams
instance
Arbitrary
AddContactParams
where
arbitrary
=
elements
[
AddContactParams
"Pierre"
"Dupont"
]
------------------------------------------------------------------------
src/Gargantext/API/Node/Corpus/Annuaire.hs
View file @
1aa7eefa
...
@@ -74,30 +74,11 @@ addToAnnuaireWithForm _cid (AnnuaireWithForm ft _d _l) logStatus = do
...
@@ -74,30 +74,11 @@ addToAnnuaireWithForm _cid (AnnuaireWithForm ft _d _l) logStatus = do
printDebug
"ft"
ft
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 <- liftBase
-- $ splitEvery 500
-- <$> take 1000000
-- <$> parse (cs d)
logStatus
JobLog
{
_scst_succeeded
=
Just
1
logStatus
JobLog
{
_scst_succeeded
=
Just
1
,
_scst_failed
=
Just
0
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
1
,
_scst_remaining
=
Just
1
,
_scst_events
=
Just
[]
,
_scst_events
=
Just
[]
}
}
-- cid' <- flowCorpus "user1"
-- (Right [cid])
-- (Multi $ fromMaybe EN l)
-- (map (map toHyperdataDocument) docs)
-- printDebug "cid'" cid'
pure
JobLog
{
_scst_succeeded
=
Just
2
pure
JobLog
{
_scst_succeeded
=
Just
2
,
_scst_failed
=
Just
0
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
0
,
_scst_remaining
=
Just
0
...
...
src/Gargantext/API/Node/Corpus/Export.hs
View file @
1aa7eefa
...
@@ -19,22 +19,19 @@ Main exports of Gargantext:
...
@@ -19,22 +19,19 @@ Main exports of Gargantext:
module
Gargantext.API.Node.Corpus.Export
module
Gargantext.API.Node.Corpus.Export
where
where
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Aeson.TH
(
deriveJSON
)
import
qualified
Data.List
as
List
import
qualified
Data.Map
as
Map
import
Data.Map
(
Map
)
import
Data.Map
(
Map
)
import
Data.Maybe
(
fromMaybe
)
import
Data.Maybe
(
fromMaybe
)
import
Data.Set
(
Set
)
import
Data.Set
(
Set
)
import
qualified
Data.Set
as
Set
import
Data.Swagger
import
Data.Swagger
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
GHC.Generics
(
Generic
)
import
GHC.Generics
(
Generic
)
import
Servant
import
Gargantext.API.Ngrams
import
Gargantext.API.Ngrams
import
Gargantext.API.Ngrams.Tools
(
filterListWithRoot
,
mapTermListRoot
,
getRepo
)
import
Gargantext.API.Ngrams.Tools
(
filterListWithRoot
,
mapTermListRoot
,
getRepo
)
import
Gargantext.API.Prelude
(
GargNoServer
)
import
Gargantext.API.Prelude
(
GargNoServer
)
import
Gargantext.Core.Types
--
import
Gargantext.Core.Crypto.Hash
(
hash
)
import
Gargantext.Core.Types
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
)
import
Gargantext.Database.Action.Metrics.NgramsByNode
(
getNgramsByNodeOnlyUser
)
import
Gargantext.Database.Action.Metrics.NgramsByNode
(
getNgramsByNodeOnlyUser
)
import
Gargantext.Database.Admin.Config
(
userMaster
)
import
Gargantext.Database.Admin.Config
(
userMaster
)
...
@@ -42,13 +39,16 @@ import Gargantext.Database.Admin.Types.Hyperdata (HyperdataDocument(..))
...
@@ -42,13 +39,16 @@ import Gargantext.Database.Admin.Types.Hyperdata (HyperdataDocument(..))
import
Gargantext.Database.Admin.Types.Node
(
Node
,
NodeId
,
ListId
,
CorpusId
)
import
Gargantext.Database.Admin.Types.Node
(
Node
,
NodeId
,
ListId
,
CorpusId
)
import
Gargantext.Database.Prelude
(
Cmd
)
import
Gargantext.Database.Prelude
(
Cmd
)
import
Gargantext.Database.Query.Table.Node
import
Gargantext.Database.Query.Table.Node
import
Gargantext.Database.Query.Table.Node.Select
(
selectNodesWithUsername
)
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
)
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
)
import
Gargantext.Database.Query.Table.Node.Select
(
selectNodesWithUsername
)
import
Gargantext.Database.Query.Table.NodeNode
(
selectDocNodes
)
import
Gargantext.Database.Query.Table.NodeNode
(
selectDocNodes
)
import
Gargantext.Database.Schema.Node
(
_node_id
,
_node_hyperdata
)
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
(
..
))
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
(
..
))
import
Gargantext.Database.Schema.Node
(
_node_id
,
_node_hyperdata
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Prelude.Utils
(
hash
)
import
Servant
import
qualified
Data.List
as
List
import
qualified
Data.Map
as
Map
import
qualified
Data.Set
as
Set
-- Corpus Export
-- Corpus Export
...
...
src/Gargantext/API/Node/Corpus/New.hs
View file @
1aa7eefa
...
@@ -213,12 +213,12 @@ addToCorpusWithQuery u cid (WithQuery q dbs l _nid) logStatus = do
...
@@ -213,12 +213,12 @@ addToCorpusWithQuery u cid (WithQuery q dbs l _nid) logStatus = do
,
_scst_remaining
=
Just
5
,
_scst_remaining
=
Just
5
,
_scst_events
=
Just
[]
,
_scst_events
=
Just
[]
}
}
printDebug
"addToCorpusWithQuery"
cid
printDebug
"addToCorpusWithQuery"
(
cid
,
dbs
)
-- TODO add cid
-- TODO add cid
-- TODO if cid is folder -> create Corpus
-- TODO if cid is folder -> create Corpus
-- if cid is corpus -> add to corpus
-- if cid is corpus -> add to corpus
-- if cid is root -> create corpus in Private
-- if cid is root -> create corpus in Private
txts
<-
mapM
(
\
db
->
getDataText
db
(
Multi
l
)
q
(
Just
10000
)
)
[
database2origin
dbs
]
txts
<-
mapM
(
\
db
->
getDataText
db
(
Multi
l
)
q
Nothing
)
[
database2origin
dbs
]
logStatus
JobLog
{
_scst_succeeded
=
Just
2
logStatus
JobLog
{
_scst_succeeded
=
Just
2
,
_scst_failed
=
Just
0
,
_scst_failed
=
Just
0
...
...
src/Gargantext/API/Node/Corpus/New/File.hs
View file @
1aa7eefa
...
@@ -30,7 +30,7 @@ import Gargantext.API.Ngrams (TODO)
...
@@ -30,7 +30,7 @@ import Gargantext.API.Ngrams (TODO)
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Prelude
-- (Cmd, CmdM)
import
Gargantext.Database.Prelude
-- (Cmd, CmdM)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.
Prelude.Utils
(
hash
)
import
Gargantext.
Core.Crypto.Hash
(
hash
)
import
Servant
import
Servant
import
Servant.Multipart
import
Servant.Multipart
import
Servant.Swagger
(
HasSwagger
(
toSwagger
))
import
Servant.Swagger
(
HasSwagger
(
toSwagger
))
...
...
src/Gargantext/API/Node/Update.hs
View file @
1aa7eefa
...
@@ -41,10 +41,10 @@ type API = Summary " Update node according to NodeType params"
...
@@ -41,10 +41,10 @@ type API = Summary " Update node according to NodeType params"
:>
AsyncJobs
JobLog
'[
J
SON
]
UpdateNodeParams
JobLog
:>
AsyncJobs
JobLog
'[
J
SON
]
UpdateNodeParams
JobLog
------------------------------------------------------------------------
------------------------------------------------------------------------
data
UpdateNodeParams
=
UpdateNodeParamsList
{
methodList
::
Method
}
data
UpdateNodeParams
=
UpdateNodeParamsList
{
methodList
::
!
Method
}
|
UpdateNodeParamsGraph
{
methodGraph
::
GraphMetric
}
|
UpdateNodeParamsGraph
{
methodGraph
::
!
GraphMetric
}
|
UpdateNodeParamsTexts
{
methodTexts
::
Granularity
}
|
UpdateNodeParamsTexts
{
methodTexts
::
!
Granularity
}
|
UpdateNodeParamsBoard
{
methodBoard
::
Charts
}
|
UpdateNodeParamsBoard
{
methodBoard
::
!
Charts
}
deriving
(
Generic
)
deriving
(
Generic
)
----------------------------------------------------------------------
----------------------------------------------------------------------
...
...
src/Gargantext/API/Routes.hs
View file @
1aa7eefa
...
@@ -7,7 +7,6 @@ Maintainer : team@gargantext.org
...
@@ -7,7 +7,6 @@ Maintainer : team@gargantext.org
Stability : experimental
Stability : experimental
Portability : POSIX
Portability : POSIX
-}
-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
...
@@ -51,7 +50,7 @@ import qualified Gargantext.API.Node.Corpus.Annuaire as Annuaire
...
@@ -51,7 +50,7 @@ import qualified Gargantext.API.Node.Corpus.Annuaire as Annuaire
import
qualified
Gargantext.API.Node.Corpus.Export
as
Export
import
qualified
Gargantext.API.Node.Corpus.Export
as
Export
import
qualified
Gargantext.API.Node.Corpus.New
as
New
import
qualified
Gargantext.API.Node.Corpus.New
as
New
import
qualified
Gargantext.API.Public
as
Public
import
qualified
Gargantext.API.Public
as
Public
import
qualified
Gargantext.API.Node.Contact
as
Contact
type
GargAPI
=
"api"
:>
Summary
"API "
:>
GargAPIVersion
type
GargAPI
=
"api"
:>
Summary
"API "
:>
GargAPIVersion
-- | TODO :<|> Summary "Latest API" :> GargAPI'
-- | TODO :<|> Summary "Latest API" :> GargAPI'
...
@@ -116,9 +115,7 @@ type GargPrivateAPI' =
...
@@ -116,9 +115,7 @@ type GargPrivateAPI' =
:<|>
"annuaire"
:>
Summary
"Contact endpoint"
:<|>
"annuaire"
:>
Summary
"Contact endpoint"
:>
Capture
"annuaire_id"
NodeId
:>
Capture
"annuaire_id"
NodeId
:>
"contact"
:>
Contact
.
API
:>
Capture
"contact_id"
NodeId
:>
NodeNodeAPI
HyperdataContact
-- Document endpoint
-- Document endpoint
:<|>
"document"
:>
Summary
"Document endpoint"
:<|>
"document"
:>
Summary
"Document endpoint"
...
@@ -208,7 +205,7 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
...
@@ -208,7 +205,7 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
:<|>
nodeNodeAPI
(
Proxy
::
Proxy
HyperdataAny
)
uid
:<|>
nodeNodeAPI
(
Proxy
::
Proxy
HyperdataAny
)
uid
:<|>
Export
.
getCorpus
-- uid
:<|>
Export
.
getCorpus
-- uid
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataAnnuaire
)
uid
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataAnnuaire
)
uid
:<|>
nodeNodeAPI
(
Proxy
::
Proxy
HyperdataContact
)
uid
:<|>
Contact
.
api
uid
:<|>
withAccess
(
Proxy
::
Proxy
TableNgramsApi
)
Proxy
uid
:<|>
withAccess
(
Proxy
::
Proxy
TableNgramsApi
)
Proxy
uid
<$>
PathNode
<*>
apiNgramsTableDoc
<$>
PathNode
<*>
apiNgramsTableDoc
...
@@ -246,7 +243,6 @@ waitAPI n = do
...
@@ -246,7 +243,6 @@ waitAPI n = do
pure
$
"Waited: "
<>
(
cs
$
show
n
)
pure
$
"Waited: "
<>
(
cs
$
show
n
)
----------------------------------------
----------------------------------------
addCorpusWithQuery
::
User
->
GargServer
New
.
AddWithQuery
addCorpusWithQuery
::
User
->
GargServer
New
.
AddWithQuery
addCorpusWithQuery
user
cid
=
addCorpusWithQuery
user
cid
=
serveJobsAPI
$
serveJobsAPI
$
...
...
src/Gargantext/API/Search.hs
View file @
1aa7eefa
...
@@ -28,7 +28,7 @@ import Gargantext.API.Prelude (GargServer)
...
@@ -28,7 +28,7 @@ import Gargantext.API.Prelude (GargServer)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
)
import
Gargantext.Database.Query.Facet
import
Gargantext.Database.Query.Facet
import
Gargantext.Database.Action.Search
import
Gargantext.Database.Action.Search
import
Gargantext.Database.Admin.Types.Hyperdata
(
Hyperdata
Documen
t
)
import
Gargantext.Database.Admin.Types.Hyperdata
(
Hyperdata
Contac
t
)
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Servant
import
Servant
...
@@ -60,7 +60,7 @@ instance ToSchema SearchDocResults where
...
@@ -60,7 +60,7 @@ instance ToSchema SearchDocResults where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"sdr_"
)
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"sdr_"
)
data
SearchPairedResults
=
data
SearchPairedResults
=
SearchPairedResults
{
spr_results
::
[
FacetPaired
Int
UTCTime
Hyperdata
Document
Int
[
Pair
Int
Text
]
]
}
SearchPairedResults
{
spr_results
::
[
FacetPaired
Int
UTCTime
Hyperdata
Contact
Int
]
}
deriving
(
Generic
)
deriving
(
Generic
)
$
(
deriveJSON
(
unPrefix
"spr_"
)
''
S
earchPairedResults
)
$
(
deriveJSON
(
unPrefix
"spr_"
)
''
S
earchPairedResults
)
...
@@ -89,12 +89,12 @@ searchDocs nId (SearchQuery q) o l order =
...
@@ -89,12 +89,12 @@ searchDocs nId (SearchQuery q) o l order =
-----------------------------------------------------------------------
-----------------------------------------------------------------------
type
SearchPairsAPI
=
Summary
""
type
SearchPairsAPI
=
Summary
""
:>
"list"
:>
"list"
:>
Capture
"
list"
List
Id
:>
Capture
"
annuaire"
Annuaire
Id
:>
SearchAPI
SearchPairedResults
:>
SearchAPI
SearchPairedResults
searchPairs
::
NodeId
->
GargServer
SearchPairsAPI
searchPairs
::
NodeId
->
GargServer
SearchPairsAPI
searchPairs
pId
l
Id
(
SearchQuery
q
)
o
l
order
=
searchPairs
pId
a
Id
(
SearchQuery
q
)
o
l
order
=
SearchPairedResults
<$>
searchInCorpusWithContacts
pId
l
Id
q
o
l
order
SearchPairedResults
<$>
searchInCorpusWithContacts
pId
a
Id
q
o
l
order
-----------------------------------------------------------------------
-----------------------------------------------------------------------
src/Gargantext/Core/Crypto/Hash.hs
0 → 100644
View file @
1aa7eefa
{-|
Module : Gargantext.Core.Crypto.Hash
Description : Useful Tools near Prelude of the project
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module
Gargantext.Core.Crypto.Hash
where
import
Prelude
(
String
)
import
Data.Set
(
Set
)
import
Data.List
(
foldl
)
import
Data.Text
(
Text
)
import
Gargantext.Prelude
import
qualified
Data.ByteString.Lazy.Char8
as
Char
import
qualified
Data.Digest.Pure.SHA
as
SHA
(
sha256
,
showDigest
)
import
qualified
Data.Set
as
Set
import
qualified
Data.Text
as
Text
--------------------------------------------------------------------------
-- | Use this datatype to keep traceability of hashes
-- TODO use newtype
type
Hash
=
Text
-- | Class to make hashes
class
IsHashable
a
where
hash
::
a
->
Hash
-- | Main API to hash text
-- using sha256 for now
instance
IsHashable
Char
.
ByteString
where
hash
=
Text
.
pack
.
SHA
.
showDigest
.
SHA
.
sha256
instance
{-# OVERLAPPING #-}
IsHashable
String
where
hash
=
hash
.
Char
.
pack
instance
IsHashable
Text
where
hash
=
hash
.
Text
.
unpack
instance
IsHashable
(
Set
Hash
)
where
hash
=
hash
.
foldl
(
<>
)
""
.
Set
.
toList
instance
{-# OVERLAPPABLE #-}
IsHashable
a
=>
IsHashable
[
a
]
where
hash
=
hash
.
Set
.
fromList
.
map
hash
src/Gargantext/Core/Crypto/Pass.hs
0 → 100644
View file @
1aa7eefa
{-|
Module : Gargantext.Core.Crypto.Pass
Description :
Copyright : (c) CNRS, 2017-Present
License : Public Domain
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
To avoid weak password, just offer an easy way to make "good" one and
let user add his own entropy.
Thanks to
https://zuttobenkyou.wordpress.com/2011/12/23/simple-password-generation-with-haskell/
-}
module
Gargantext.Core.Crypto.Pass
where
-- import Data.List (nub)
-- import System.Environment (getArgs)
-- import System.IO (hSetEcho)
import
Control.Monad.State
import
Crypto.Random
(
cprgGenerate
)
import
Crypto.Random.AESCtr
import
Data.Binary
(
decode
)
import
Prelude
import
qualified
Data.ByteString.Lazy
as
B
keysChar
,
keysNum
,
keysPunc
,
keysCharNum
,
keysAll
,
keysHex
::
String
keysChar
=
[
'a'
..
'z'
]
++
[
'A'
..
'Z'
]
keysHex
=
[
'a'
..
'f'
]
keysNum
=
[
'0'
..
'9'
]
keysPunc
=
"`~!@#$%^&*()-_=+[{]}
\\
|;:'
\"
,<.>/? "
keysCharNum
=
keysChar
++
keysNum
keysAll
=
keysChar
++
keysNum
++
keysPunc
giveKey
::
String
->
Char
->
Int
->
Char
giveKey
keysCustom
c
n
=
extractChar
$
case
c
of
'i'
->
(
keysNum
++
keysHex
)
'j'
->
keysNum
'k'
->
keysChar
'l'
->
keysCharNum
';'
->
keysPunc
'h'
->
(
keysCharNum
++
keysCustom
)
'
\n
'
->
[
'
\n
'
]
_
->
keysAll
where
extractChar
xs
=
xs
!!
mod
n
(
length
xs
)
showRandomKey
::
Int
->
String
->
StateT
AESRNG
IO
()
showRandomKey
len
keysCustom
=
handleKey
=<<
liftIO
getChar
where
handleKey
key
=
case
key
of
'
\n
'
->
liftIO
(
putChar
'
\n
'
)
>>
showRandomKey
len
keysCustom
'q'
->
(
liftIO
$
putStrLn
"
\n
Bye!"
)
>>
return
()
_
->
mapM_
f
[
0
..
len
]
>>
(
liftIO
$
putStrLn
[]
)
>>
showRandomKey
len
keysCustom
where
f
_
=
liftIO
.
putChar
.
giveKey
keysCustom
key
.
(
\
n
->
mod
n
(
length
(
keysAll
++
keysCustom
)
-
1
))
=<<
aesRandomInt
aesRandomInt
::
StateT
AESRNG
IO
Int
aesRandomInt
=
do
aesState
<-
get
-- aesState <- liftIO makeSystem
-- let aesState = 128
let
(
bs
,
aesState'
)
=
cprgGenerate
64
aesState
put
aesState'
return
(
decode
$
B
.
fromChunks
[
bs
])
gargPass
::
IO
(
Int
,
AESRNG
)
gargPass
=
do
-- let as = ["alphanumeric","punctuation"]
-- let as' = filter (\c -> elem c keysAll) . nub $ unwords as
aesState
<-
makeSystem
-- gather entropy from the system to use as the initial seed
--
_
<-
runStateT
(
showRandomKey
len
as'
)
aesState
-- enter loop
-- return ()
pass
<-
runStateT
aesRandomInt
aesState
-- enter loop
pure
pass
{-
main :: IO ()
main = do
hSetBuffering stdin NoBuffering -- disable buffering from STDIN
hSetBuffering stdout NoBuffering -- disable buffering from STDOUT
hSetEcho stdin False -- disable terminal echo
as <- getArgs
let as' = filter (\c -> elem c keysAll) . nub $ unwords as
mapM_ putStrLn
[ []
, "poke: 'q' quit"
, " 'j' number"
, " 'k' letter"
, " 'l' alphanumeric"
, " ';' punctuation"
, " 'h' alphanumeric" ++ (if null as' then [] else " + " ++ as')
, " 'i' hexadecimal"
, " 'ENTER' newline"
, " else any"
, []
]
aesState <- makeSystem -- gather entropy from the system to use as the initial seed
_ <- runStateT (showRandomKey as') aesState -- enter loop
return ()
-}
src/Gargantext/Core/Mail.hs
0 → 100644
View file @
1aa7eefa
{-|
Module : Gargantext.Core.Mail
Description :
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE OverloadedStrings #-}
module
Gargantext.Core.Mail
(
gargMail
)
where
import
Data.Maybe
import
Network.Mail.SMTP
hiding
(
htmlPart
)
import
Gargantext.Prelude
import
Network.Mail.Mime
(
plainPart
)
-- | TODO add parameters
gargMail
::
IO
()
gargMail
=
sendMail
"localhost"
mail
where
mail
=
simpleMail
from
to
cc
bcc
subject
[
body
]
from
=
Address
(
Just
"François Rabelais"
)
"francois.rabelais@gargantext.org"
to
=
[
Address
(
Just
"Anoe"
)
"alexandre@localhost"
]
cc
=
[]
bcc
=
[]
subject
=
"email subject"
body
=
plainPart
"email body"
src/Gargantext/Database.hs
View file @
1aa7eefa
...
@@ -16,12 +16,40 @@ Gargantext's database.
...
@@ -16,12 +16,40 @@ Gargantext's database.
module
Gargantext.Database
(
module
Gargantext
.
Database
.
Prelude
module
Gargantext.Database
(
module
Gargantext
.
Database
.
Prelude
,
module
Gargantext
.
Database
.
Schema
.
NodeNode
,
insertDB
-- , module Gargantext.Database.Bashql
-- , module Gargantext.Database.Bashql
)
)
where
where
import
Gargantext.
Database.Prelude
(
connectGargandb
)
import
Gargantext.
Prelude
-- import Gargantext.Database.Bashql
import
Gargantext.Database.Prelude
-- (connectGargandb)
-- import Gargantext.Database.Schema.Node
-- import Gargantext.Database.Query.Table.Node
import
Gargantext.Database.Schema.NodeNode
-- (NodeNode(..))
import
Gargantext.Database.Query.Table.NodeNode
class
InsertDB
a
where
insertDB
::
a
->
Cmd
err
Int
{-
class DeleteDB a where
deleteDB :: a -> Cmd err Int
-}
instance
InsertDB
[
NodeNode
]
where
insertDB
=
insertNodeNode
{-
instance InsertDB [Node a] where
insertDB = insertNodes'
instance InsertDB [NodeNodeNgram] where
insertDB = ...
-}
src/Gargantext/Database/Action/Flow.hs
View file @
1aa7eefa
...
@@ -27,6 +27,7 @@ module Gargantext.Database.Action.Flow -- (flowDatabase, ngrams2list)
...
@@ -27,6 +27,7 @@ module Gargantext.Database.Action.Flow -- (flowDatabase, ngrams2list)
(
FlowCmdM
(
FlowCmdM
,
getDataText
,
getDataText
,
flowDataText
,
flowDataText
,
flow
,
flowCorpusFile
,
flowCorpusFile
,
flowCorpus
,
flowCorpus
...
@@ -68,7 +69,7 @@ import Gargantext.Database.Action.Flow.Utils (insertDocNgrams)
...
@@ -68,7 +69,7 @@ import Gargantext.Database.Action.Flow.Utils (insertDocNgrams)
import
Gargantext.Database.Query.Table.Node
import
Gargantext.Database.Query.Table.Node
import
Gargantext.Database.Query.Table.Node.Document.Insert
-- (insertDocuments, ReturnId(..), addUniqIdsDoc, addUniqIdsContact, ToDbData(..))
import
Gargantext.Database.Query.Table.Node.Document.Insert
-- (insertDocuments, ReturnId(..), addUniqIdsDoc, addUniqIdsContact, ToDbData(..))
import
Gargantext.Database.Query.Tree.Root
(
getOrMkRoot
,
getOrMk_RootWithCorpus
)
import
Gargantext.Database.Query.Tree.Root
(
getOrMkRoot
,
getOrMk_RootWithCorpus
)
import
Gargantext.Database.Action.Search
(
searchInDatabase
)
import
Gargantext.Database.Action.Search
(
search
Doc
InDatabase
)
import
Gargantext.Database.Admin.Config
(
userMaster
,
corpusMasterName
)
import
Gargantext.Database.Admin.Config
(
userMaster
,
corpusMasterName
)
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
(
..
))
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
(
..
))
import
Gargantext.Database.Admin.Types.Hyperdata
import
Gargantext.Database.Admin.Types.Hyperdata
...
@@ -106,11 +107,9 @@ allDataOrigins = map InternalOrigin API.externalAPIs
...
@@ -106,11 +107,9 @@ allDataOrigins = map InternalOrigin API.externalAPIs
<>
map
ExternalOrigin
API
.
externalAPIs
<>
map
ExternalOrigin
API
.
externalAPIs
---------------
---------------
data
DataText
=
DataOld
!
[
NodeId
]
data
DataText
=
DataOld
!
[
NodeId
]
|
DataNew
!
[[
HyperdataDocument
]]
|
DataNew
!
[[
HyperdataDocument
]]
-- TODO use the split parameter in config file
-- TODO use the split parameter in config file
getDataText
::
FlowCmdM
env
err
m
getDataText
::
FlowCmdM
env
err
m
=>
DataOrigin
=>
DataOrigin
...
@@ -126,7 +125,7 @@ getDataText (InternalOrigin _) _la q _li = do
...
@@ -126,7 +125,7 @@ getDataText (InternalOrigin _) _la q _li = do
(
UserName
userMaster
)
(
UserName
userMaster
)
(
Left
""
)
(
Left
""
)
(
Nothing
::
Maybe
HyperdataCorpus
)
(
Nothing
::
Maybe
HyperdataCorpus
)
ids
<-
map
fst
<$>
searchInDatabase
cId
(
stemIt
q
)
ids
<-
map
fst
<$>
search
Doc
InDatabase
cId
(
stemIt
q
)
pure
$
DataOld
ids
pure
$
DataOld
ids
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
...
...
src/Gargantext/Database/Action/Flow/Pairing.hs
View file @
1aa7eefa
This diff is collapsed.
Click to expand it.
src/Gargantext/Database/Action/Learn.hs
View file @
1aa7eefa
...
@@ -34,9 +34,9 @@ data FavOrTrash = IsFav | IsTrash
...
@@ -34,9 +34,9 @@ data FavOrTrash = IsFav | IsTrash
moreLike
::
CorpusId
->
Maybe
Offset
->
Maybe
Limit
->
Maybe
OrderBy
moreLike
::
CorpusId
->
Maybe
Offset
->
Maybe
Limit
->
Maybe
OrderBy
->
FavOrTrash
->
Cmd
err
[
FacetDoc
]
->
FavOrTrash
->
Cmd
err
[
FacetDoc
]
moreLike
cId
o
l
order
ft
=
do
moreLike
cId
o
_
l
order
ft
=
do
priors
<-
getPriors
ft
cId
priors
<-
getPriors
ft
cId
moreLikeWith
cId
o
l
order
ft
priors
moreLikeWith
cId
o
(
Just
3
)
order
ft
priors
---------------------------------------------------------------------------
---------------------------------------------------------------------------
getPriors
::
FavOrTrash
->
CorpusId
->
Cmd
err
(
Events
Bool
)
getPriors
::
FavOrTrash
->
CorpusId
->
Cmd
err
(
Events
Bool
)
...
...
src/Gargantext/Database/Action/Node.hs
View file @
1aa7eefa
...
@@ -28,7 +28,7 @@ import Gargantext.Database.Query.Table.Node
...
@@ -28,7 +28,7 @@ import Gargantext.Database.Query.Table.Node
import
Gargantext.Database.Query.Table.Node.Error
import
Gargantext.Database.Query.Table.Node.Error
import
Gargantext.Database.Query.Table.Node.UpdateOpaleye
(
updateHyperdata
)
import
Gargantext.Database.Query.Table.Node.UpdateOpaleye
(
updateHyperdata
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.
Prelude.Utils
(
hash
)
import
Gargantext.
Core.Crypto.Hash
(
hash
)
import
Gargantext.Database.Prelude
import
Gargantext.Database.Prelude
import
Control.Lens
(
view
)
import
Control.Lens
(
view
)
import
Gargantext.Config
(
GargConfig
(
..
))
import
Gargantext.Config
(
GargConfig
(
..
))
...
...
src/Gargantext/Database/Action/Search.hs
View file @
1aa7eefa
This diff is collapsed.
Click to expand it.
src/Gargantext/Database/Action/Share.hs
View file @
1aa7eefa
...
@@ -14,6 +14,7 @@ module Gargantext.Database.Action.Share
...
@@ -14,6 +14,7 @@ module Gargantext.Database.Action.Share
where
where
import
Control.Lens
(
view
)
import
Control.Lens
(
view
)
import
Gargantext.Database
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Database.Action.Flow.Utils
(
getUserId
)
import
Gargantext.Database.Action.Flow.Utils
(
getUserId
)
import
Gargantext.Database.Admin.Config
(
hasNodeType
,
isInNodeTypes
)
import
Gargantext.Database.Admin.Config
(
hasNodeType
,
isInNodeTypes
)
...
@@ -23,7 +24,7 @@ import Gargantext.Database.Admin.Types.Node -- (NodeType(..))
...
@@ -23,7 +24,7 @@ import Gargantext.Database.Admin.Types.Node -- (NodeType(..))
import
Gargantext.Database.Prelude
(
Cmd
)
import
Gargantext.Database.Prelude
(
Cmd
)
import
Gargantext.Database.Query.Table.Node
(
getNode
,
getNodesWith
)
import
Gargantext.Database.Query.Table.Node
(
getNode
,
getNodesWith
)
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
,
errorWith
)
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
,
errorWith
)
import
Gargantext.Database.Query.Table.NodeNode
(
insertNodeNode
,
deleteNodeNode
)
import
Gargantext.Database.Query.Table.NodeNode
(
deleteNodeNode
)
import
Gargantext.Database.Query.Tree.Root
(
getRootId
)
import
Gargantext.Database.Query.Tree.Root
(
getRootId
)
import
Gargantext.Database.Schema.Node
import
Gargantext.Database.Schema.Node
import
Gargantext.Database.Schema.NodeNode
(
NodeNodePoly
(
..
))
import
Gargantext.Database.Schema.NodeNode
(
NodeNodePoly
(
..
))
...
@@ -45,7 +46,7 @@ data ShareNodeWith = ShareNodeWith_User { snwu_nodetype :: NodeType
...
@@ -45,7 +46,7 @@ data ShareNodeWith = ShareNodeWith_User { snwu_nodetype :: NodeType
shareNodeWith
::
HasNodeError
err
shareNodeWith
::
HasNodeError
err
=>
ShareNodeWith
=>
ShareNodeWith
->
NodeId
->
NodeId
->
Cmd
err
Int
64
->
Cmd
err
Int
shareNodeWith
(
ShareNodeWith_User
NodeFolderShared
u
)
n
=
do
shareNodeWith
(
ShareNodeWith_User
NodeFolderShared
u
)
n
=
do
nodeToCheck
<-
getNode
n
nodeToCheck
<-
getNode
n
userIdCheck
<-
getUserId
u
userIdCheck
<-
getUserId
u
...
@@ -56,7 +57,7 @@ shareNodeWith (ShareNodeWith_User NodeFolderShared u) n = do
...
@@ -56,7 +57,7 @@ shareNodeWith (ShareNodeWith_User NodeFolderShared u) n = do
then
errorWith
"[G.D.A.S.shareNodeWith] Can share to others only"
then
errorWith
"[G.D.A.S.shareNodeWith] Can share to others only"
else
do
else
do
folderSharedId
<-
getFolderId
u
NodeFolderShared
folderSharedId
<-
getFolderId
u
NodeFolderShared
insert
NodeNode
[
NodeNode
folderSharedId
n
Nothing
Nothing
]
insert
DB
([
NodeNode
folderSharedId
n
Nothing
Nothing
]
::
[
NodeNode
])
shareNodeWith
(
ShareNodeWith_Node
NodeFolderPublic
nId
)
n
=
do
shareNodeWith
(
ShareNodeWith_Node
NodeFolderPublic
nId
)
n
=
do
nodeToCheck
<-
getNode
n
nodeToCheck
<-
getNode
n
...
@@ -66,7 +67,7 @@ shareNodeWith (ShareNodeWith_Node NodeFolderPublic nId) n = do
...
@@ -66,7 +67,7 @@ shareNodeWith (ShareNodeWith_Node NodeFolderPublic nId) n = do
else
do
else
do
folderToCheck
<-
getNode
nId
folderToCheck
<-
getNode
nId
if
hasNodeType
folderToCheck
NodeFolderPublic
if
hasNodeType
folderToCheck
NodeFolderPublic
then
insert
NodeNode
[
NodeNode
nId
n
Nothing
Nothing
]
then
insert
DB
([
NodeNode
nId
n
Nothing
Nothing
]
::
[
NodeNode
])
else
errorWith
"[G.D.A.S.shareNodeWith] Can share NodeWith NodeFolderPublic only"
else
errorWith
"[G.D.A.S.shareNodeWith] Can share NodeWith NodeFolderPublic only"
shareNodeWith
_
_
=
errorWith
"[G.D.A.S.shareNodeWith] Not implemented for this NodeType"
shareNodeWith
_
_
=
errorWith
"[G.D.A.S.shareNodeWith] Not implemented for this NodeType"
...
...
src/Gargantext/Database/Admin/Config.hs
View file @
1aa7eefa
src/Gargantext/Database/Admin/Types/Hyperdata/Contact.hs
View file @
1aa7eefa
...
@@ -54,6 +54,15 @@ defaultHyperdataContact = HyperdataContact (Just "bdd")
...
@@ -54,6 +54,15 @@ defaultHyperdataContact = HyperdataContact (Just "bdd")
(
Just
"DO NOT expose this"
)
(
Just
"DO NOT expose this"
)
(
Just
"DO NOT expose this"
)
(
Just
"DO NOT expose this"
)
hyperdataContact
::
FirstName
->
LastName
->
HyperdataContact
hyperdataContact
fn
ln
=
HyperdataContact
Nothing
(
Just
(
contactWho
fn
ln
))
[]
Nothing
Nothing
Nothing
Nothing
Nothing
-- TOD0 contact metadata (Type is too flat)
-- TOD0 contact metadata (Type is too flat)
data
ContactMetaData
=
data
ContactMetaData
=
...
@@ -78,12 +87,20 @@ data ContactWho =
...
@@ -78,12 +87,20 @@ data ContactWho =
,
_cw_freetags
::
[
Text
]
,
_cw_freetags
::
[
Text
]
}
deriving
(
Eq
,
Show
,
Generic
)
}
deriving
(
Eq
,
Show
,
Generic
)
type
FirstName
=
Text
type
LastName
=
Text
defaultContactWho
::
ContactWho
defaultContactWho
::
ContactWho
defaultContactWho
=
ContactWho
(
Just
"123123"
)
defaultContactWho
=
contactWho
"Pierre"
"Dupont"
(
Just
"First Name"
)
(
Just
"Last Name"
)
contactWho
::
FirstName
->
LastName
->
ContactWho
[
"keyword A"
]
contactWho
fn
ln
=
ContactWho
Nothing
[
"freetag A"
]
(
Just
fn
)
(
Just
ln
)
[]
[]
data
ContactWhere
=
data
ContactWhere
=
ContactWhere
{
_cw_organization
::
[
Text
]
ContactWhere
{
_cw_organization
::
[
Text
]
...
@@ -150,6 +167,12 @@ instance FromField HyperdataContact where
...
@@ -150,6 +167,12 @@ instance FromField HyperdataContact where
instance
QueryRunnerColumnDefault
PGJsonb
HyperdataContact
where
instance
QueryRunnerColumnDefault
PGJsonb
HyperdataContact
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
instance
QueryRunnerColumnDefault
(
Nullable
PGJsonb
)
HyperdataContact
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
-- | All lenses
-- | All lenses
makeLenses
''
C
ontactWho
makeLenses
''
C
ontactWho
makeLenses
''
C
ontactWhere
makeLenses
''
C
ontactWhere
...
...
src/Gargantext/Database/Admin/Types/Hyperdata/Prelude.hs
View file @
1aa7eefa
...
@@ -48,7 +48,7 @@ import GHC.Generics (Generic)
...
@@ -48,7 +48,7 @@ import GHC.Generics (Generic)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
,
wellNamedSchema
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
,
wellNamedSchema
)
import
Gargantext.Database.Prelude
(
fromField'
)
import
Gargantext.Database.Prelude
(
fromField'
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Opaleye
(
QueryRunnerColumnDefault
,
queryRunnerColumnDefault
,
PGJsonb
,
fieldQueryRunnerColumn
)
import
Opaleye
(
QueryRunnerColumnDefault
,
queryRunnerColumnDefault
,
PGJsonb
,
fieldQueryRunnerColumn
,
Nullable
)
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
import
Test.QuickCheck.Arbitrary
...
...
src/Gargantext/Database/Admin/Types/Node.hs
View file @
1aa7eefa
...
@@ -157,6 +157,7 @@ instance Arbitrary NodeId where
...
@@ -157,6 +157,7 @@ instance Arbitrary NodeId where
type
ParentId
=
NodeId
type
ParentId
=
NodeId
type
CorpusId
=
NodeId
type
CorpusId
=
NodeId
type
CommunityId
=
NodeId
type
ListId
=
NodeId
type
ListId
=
NodeId
type
DocumentId
=
NodeId
type
DocumentId
=
NodeId
type
DocId
=
NodeId
type
DocId
=
NodeId
...
@@ -241,6 +242,8 @@ data NodeType = NodeUser
...
@@ -241,6 +242,8 @@ data NodeType = NodeUser
|
NodeFolderPublic
|
NodeFolderPublic
|
NodeFolder
|
NodeFolder
-- | NodeAnalysis | NodeCommunity
|
NodeCorpus
|
NodeCorpusV3
|
NodeTexts
|
NodeDocument
|
NodeCorpus
|
NodeCorpusV3
|
NodeTexts
|
NodeDocument
|
NodeAnnuaire
|
NodeContact
|
NodeAnnuaire
|
NodeContact
|
NodeGraph
|
NodePhylo
|
NodeGraph
|
NodePhylo
...
@@ -336,4 +339,7 @@ instance QueryRunnerColumnDefault (Nullable PGInt4) NodeId
...
@@ -336,4 +339,7 @@ instance QueryRunnerColumnDefault (Nullable PGInt4) NodeId
where
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
instance
(
QueryRunnerColumnDefault
(
Nullable
O
.
PGTimestamptz
)
UTCTime
)
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
src/Gargantext/Database/Prelude.hs
View file @
1aa7eefa
...
@@ -45,7 +45,6 @@ import qualified Data.List as DL
...
@@ -45,7 +45,6 @@ import qualified Data.List as DL
import
qualified
Database.PostgreSQL.Simple
as
PGS
import
qualified
Database.PostgreSQL.Simple
as
PGS
-------------------------------------------------------
-------------------------------------------------------
class
HasConnectionPool
env
where
class
HasConnectionPool
env
where
connPool
::
Getter
env
(
Pool
Connection
)
connPool
::
Getter
env
(
Pool
Connection
)
...
...
src/Gargantext/Database/Query/Facet.hs
View file @
1aa7eefa
...
@@ -29,6 +29,8 @@ module Gargantext.Database.Query.Facet
...
@@ -29,6 +29,8 @@ module Gargantext.Database.Query.Facet
,
FacetDocRead
,
FacetDocRead
,
FacetPaired
(
..
)
,
FacetPaired
(
..
)
,
FacetPairedRead
,
FacetPairedRead
,
FacetPairedReadNull
,
FacetPairedReadNullAgg
,
OrderBy
(
..
)
,
OrderBy
(
..
)
)
)
where
where
...
@@ -111,44 +113,61 @@ instance (Typeable i, Typeable l, ToSchema i, ToSchema l) => ToSchema (Pair i l)
...
@@ -111,44 +113,61 @@ instance (Typeable i, Typeable l, ToSchema i, ToSchema l) => ToSchema (Pair i l)
instance
(
Arbitrary
i
,
Arbitrary
l
)
=>
Arbitrary
(
Pair
i
l
)
where
instance
(
Arbitrary
i
,
Arbitrary
l
)
=>
Arbitrary
(
Pair
i
l
)
where
arbitrary
=
Pair
<$>
arbitrary
<*>
arbitrary
arbitrary
=
Pair
<$>
arbitrary
<*>
arbitrary
data
FacetPaired
id
date
hyperdata
score
pair
=
data
FacetPaired
id
date
hyperdata
score
=
FacetPaired
{
_fp_id
::
id
FacetPaired
{
_fp_id
::
id
,
_fp_date
::
date
,
_fp_date
::
date
,
_fp_hyperdata
::
hyperdata
,
_fp_hyperdata
::
hyperdata
,
_fp_score
::
score
,
_fp_score
::
score
,
_fp_pair
::
pair
}
deriving
(
Show
,
Generic
)
}
deriving
(
Show
,
Generic
)
$
(
deriveJSON
(
unPrefix
"_fp_"
)
''
F
acetPaired
)
$
(
deriveJSON
(
unPrefix
"_fp_"
)
''
F
acetPaired
)
$
(
makeAdaptorAndInstance
"pFacetPaired"
''
F
acetPaired
)
$
(
makeAdaptorAndInstance
"pFacetPaired"
''
F
acetPaired
)
instance
(
ToSchema
id
instance
(
ToSchema
id
,
ToSchema
date
,
ToSchema
date
,
ToSchema
hyperdata
,
ToSchema
hyperdata
,
ToSchema
score
,
ToSchema
score
,
ToSchema
pair
,
Typeable
id
,
Typeable
id
,
Typeable
date
,
Typeable
date
,
Typeable
hyperdata
,
Typeable
hyperdata
,
Typeable
score
,
Typeable
score
,
Typeable
pair
)
=>
ToSchema
(
FacetPaired
id
date
hyperdata
score
)
where
)
=>
ToSchema
(
FacetPaired
id
date
hyperdata
score
pair
)
where
declareNamedSchema
=
wellNamedSchema
"_fp_"
declareNamedSchema
=
wellNamedSchema
"_fp_"
instance
(
Arbitrary
id
instance
(
Arbitrary
id
,
Arbitrary
date
,
Arbitrary
date
,
Arbitrary
hyperdata
,
Arbitrary
hyperdata
,
Arbitrary
score
,
Arbitrary
score
,
Arbitrary
pair
)
=>
Arbitrary
(
FacetPaired
id
date
hyperdata
score
)
where
)
=>
Arbitrary
(
FacetPaired
id
date
hyperdata
score
pair
)
where
arbitrary
=
FacetPaired
<$>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
arbitrary
=
FacetPaired
<$>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
type
FacetPairedRead
=
FacetPaired
(
Column
PGInt4
)
type
FacetPairedRead
=
FacetPaired
(
Column
PGInt4
)
(
Column
PGTimestamptz
)
(
Column
PGTimestamptz
)
(
Column
PGJsonb
)
(
Column
PGJsonb
)
(
Column
PGInt4
)
(
Column
PGInt4
)
(
Column
(
Nullable
PGInt4
)
,
Column
(
Nullable
PGText
)
type
FacetPairedReadNull
=
FacetPaired
(
Column
(
Nullable
PGInt4
)
)
(
Column
(
Nullable
PGTimestamptz
))
(
Column
(
Nullable
PGJsonb
)
)
(
Column
(
Nullable
PGInt4
)
)
type
FacetPairedReadNullAgg
=
FacetPaired
(
Aggregator
(
Column
(
Nullable
PGInt4
)
)
(
Column
(
Nullable
PGInt4
)
)
)
(
Aggregator
(
Column
(
Nullable
PGTimestamptz
))
(
Column
(
Nullable
PGTimestamptz
))
)
)
(
Aggregator
(
Column
(
Nullable
PGJsonb
)
)
(
Column
(
Nullable
PGJsonb
)
)
)
(
Aggregator
(
Column
(
Nullable
PGInt4
)
)
(
Column
(
Nullable
PGInt4
)
)
)
-- | JSON instance
-- | JSON instance
$
(
deriveJSON
(
unPrefix
"facetDoc_"
)
''
F
acet
)
$
(
deriveJSON
(
unPrefix
"facetDoc_"
)
''
F
acet
)
...
...
src/Gargantext/Database/Query/Join.hs
View file @
1aa7eefa
...
@@ -22,7 +22,15 @@ Multiple Join functions with Opaleye.
...
@@ -22,7 +22,15 @@ Multiple Join functions with Opaleye.
------------------------------------------------------------------------
------------------------------------------------------------------------
module
Gargantext.Database.Query.Join
module
Gargantext.Database.Query.Join
(
leftJoin2
,
leftJoin3
,
leftJoin4
,
leftJoin5
,
leftJoin6
,
leftJoin7
,
leftJoin8
,
leftJoin9
)
where
where
import
Control.Applicative
((
<*>
))
import
Control.Applicative
((
<*>
))
...
@@ -33,17 +41,24 @@ import Opaleye
...
@@ -33,17 +41,24 @@ import Opaleye
import
Opaleye.Internal.Join
(
NullMaker
(
..
))
import
Opaleye.Internal.Join
(
NullMaker
(
..
))
import
qualified
Opaleye.Internal.Unpackspec
()
import
qualified
Opaleye.Internal.Unpackspec
()
--leftJoin3 :: Query columnsL1 -> Query columnsR -> Query columnsL
------------------------------------------------------------------------
-- -> ((columnsL1, columnsR) -> Column PGBool)
leftJoin2
::
(
Default
Unpackspec
fieldsL
fieldsL
,
-- -> ((columnsL, (columnsL1, nullableColumnsR1)) -> Column PGBool)
Default
Unpackspec
fieldsR
fieldsR
,
-- -> Query (columnsL, nullableColumnsR)
Default
NullMaker
fieldsR
nullableFieldsR
)
=>
--leftJoin3 q1 q2 q3 cond12 cond23 = leftJoin q3 (leftJoin q1 q2 cond12) cond23
Select
fieldsL
join3
::
Query
columnsA
->
Query
columnsB
->
Query
columnsC
->
Select
fieldsR
->
((
fieldsL
,
fieldsR
)
->
Column
PGBool
)
->
Select
(
fieldsL
,
nullableFieldsR
)
leftJoin2
=
leftJoin
------------------------------------------------------------------------
-- | LeftJoin3 in two ways to write it
_leftJoin3
::
Query
columnsA
->
Query
columnsB
->
Query
columnsC
->
((
columnsA
,
columnsB
,
columnsC
)
->
Column
PGBool
)
->
((
columnsA
,
columnsB
,
columnsC
)
->
Column
PGBool
)
->
Query
(
columnsA
,
columnsB
,
columnsC
)
->
Query
(
columnsA
,
columnsB
,
columnsC
)
join3
q1
q2
q3
cond
=
((,,)
<$>
q1
<*>
q2
<*>
q3
)
>>>
keepWhen
cond
_leftJoin3
q1
q2
q3
cond
=
((,,)
<$>
q1
<*>
q2
<*>
q3
)
>>>
keepWhen
cond
------------------------------------------------------------------------
leftJoin3
leftJoin3
::
(
Default
Unpackspec
fieldsL1
fieldsL1
,
::
(
Default
Unpackspec
fieldsL1
fieldsL1
,
Default
Unpackspec
fieldsL2
fieldsL2
,
Default
Unpackspec
fieldsL2
fieldsL2
,
...
...
src/Gargantext/Database/Query/Prelude.hs
0 → 100644
View file @
1aa7eefa
{-|
Module : Gargantext.Database.Query.Prelude
Description :
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
------------------------------------------------------------------------
module
Gargantext.Database.Query.Prelude
(
module
Gargantext
.
Database
.
Query
.
Join
,
module
Gargantext
.
Database
.
Query
.
Table
.
Node
,
module
Gargantext
.
Database
.
Query
.
Table
.
NodeNode
,
module
Control
.
Arrow
)
where
import
Control.Arrow
(
returnA
)
import
Gargantext.Database.Query.Join
import
Gargantext.Database.Query.Table.Node
import
Gargantext.Database.Query.Table.NodeNode
src/Gargantext/Database/Query/Table/Ngrams.hs
View file @
1aa7eefa
...
@@ -59,7 +59,7 @@ selectNgramsByDoc lIds dId nt = runOpaQuery (query lIds dId nt)
...
@@ -59,7 +59,7 @@ selectNgramsByDoc lIds dId nt = runOpaQuery (query lIds dId nt)
_postNgrams
::
CorpusId
->
DocId
->
[
Text
]
->
Cmd
err
Int
_postNgrams
::
CorpusId
->
DocId
->
[
Text
]
->
Cmd
err
Int
_postNgrams
=
undefined
_postNgrams
=
undefined
_dbGetNgramsDb
::
Cmd
err
[
NgramsD
b
]
_dbGetNgramsDb
::
Cmd
err
[
NgramsD
B
]
_dbGetNgramsDb
=
runOpaQuery
queryNgramsTable
_dbGetNgramsDb
=
runOpaQuery
queryNgramsTable
...
...
src/Gargantext/Database/Query/Table/Node.hs
View file @
1aa7eefa
...
@@ -190,6 +190,23 @@ node nodeType name hyperData parentId userId =
...
@@ -190,6 +190,23 @@ node nodeType name hyperData parentId userId =
insertNodes
::
[
NodeWrite
]
->
Cmd
err
Int64
insertNodes
::
[
NodeWrite
]
->
Cmd
err
Int64
insertNodes
ns
=
mkCmd
$
\
conn
->
runInsert_
conn
$
Insert
nodeTable
ns
rCount
Nothing
insertNodes
ns
=
mkCmd
$
\
conn
->
runInsert_
conn
$
Insert
nodeTable
ns
rCount
Nothing
{-
insertNodes' :: [Node a] -> Cmd err Int64
insertNodes' ns = mkCmd $ \conn -> runInsert_ conn
$ Insert nodeTable ns' rCount Nothing
where
ns' :: [NodeWrite]
ns' = map (\(Node i t u p n d h)
-> Node (pgNodeId <$> i)
(pgInt4 $ nodeTypeId t)
(pgInt4 u)
(pgNodeId <$> p)
(pgStrictText n)
(pgUTCTime <$> d)
(pgJSONB $ cs $ encode h)
) ns
-}
insertNodesR
::
[
NodeWrite
]
->
Cmd
err
[
NodeId
]
insertNodesR
::
[
NodeWrite
]
->
Cmd
err
[
NodeId
]
insertNodesR
ns
=
mkCmd
$
\
conn
->
insertNodesR
ns
=
mkCmd
$
\
conn
->
runInsert_
conn
(
Insert
nodeTable
ns
(
rReturning
(
\
(
Node
i
_
_
_
_
_
_
)
->
i
))
Nothing
)
runInsert_
conn
(
Insert
nodeTable
ns
(
rReturning
(
\
(
Node
i
_
_
_
_
_
_
)
->
i
))
Nothing
)
...
...
src/Gargantext/Database/Query/Table/Node/Children.hs
View file @
1aa7eefa
...
@@ -30,10 +30,13 @@ import Gargantext.Database.Schema.Node
...
@@ -30,10 +30,13 @@ import Gargantext.Database.Schema.Node
import
Opaleye
import
Opaleye
import
Protolude
import
Protolude
-- TODO getAllTableDocuments
getAllDocuments
::
ParentId
->
Cmd
err
(
TableResult
(
Node
HyperdataDocument
))
getAllDocuments
::
ParentId
->
Cmd
err
(
TableResult
(
Node
HyperdataDocument
))
getAllDocuments
pId
=
getAllChildren
pId
(
Proxy
::
Proxy
HyperdataDocument
)
getAllDocuments
pId
=
getAllChildren
pId
(
Proxy
::
Proxy
HyperdataDocument
)
(
Just
NodeDocument
)
(
Just
NodeDocument
)
-- TODO getAllTableContacts
getAllContacts
::
ParentId
->
Cmd
err
(
TableResult
(
Node
HyperdataContact
))
getAllContacts
::
ParentId
->
Cmd
err
(
TableResult
(
Node
HyperdataContact
))
getAllContacts
pId
=
getAllChildren
pId
(
Proxy
::
Proxy
HyperdataContact
)
getAllContacts
pId
=
getAllChildren
pId
(
Proxy
::
Proxy
HyperdataContact
)
(
Just
NodeContact
)
(
Just
NodeContact
)
...
...
src/Gargantext/Database/Query/Table/Node/Document/Insert.hs
View file @
1aa7eefa
...
@@ -72,7 +72,7 @@ import Gargantext.Database.Admin.Types.Hyperdata
...
@@ -72,7 +72,7 @@ import Gargantext.Database.Admin.Types.Hyperdata
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Prelude
(
Cmd
,
runPGSQuery
)
import
Gargantext.Database.Prelude
(
Cmd
,
runPGSQuery
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.
Prelude.Utils
(
hash
)
import
Gargantext.
Core.Crypto.Hash
(
hash
)
import
qualified
Data.Text
as
DT
(
pack
,
concat
,
take
)
import
qualified
Data.Text
as
DT
(
pack
,
concat
,
take
)
-- TODO : the import of Document constructor below does not work
-- TODO : the import of Document constructor below does not work
...
...
src/Gargantext/Database/Query/Table/NodeNode.hs
View file @
1aa7eefa
...
@@ -71,9 +71,33 @@ getNodeNode n = runOpaQuery (selectNodeNode $ pgNodeId n)
...
@@ -71,9 +71,33 @@ getNodeNode n = runOpaQuery (selectNodeNode $ pgNodeId n)
returnA
-<
ns
returnA
-<
ns
------------------------------------------------------------------------
------------------------------------------------------------------------
insertNodeNode
::
[
NodeNode
]
->
Cmd
err
Int64
-- TODO (refactor with Children)
insertNodeNode
ns
=
mkCmd
$
\
conn
->
runInsert_
conn
{-
$
Insert
nodeNodeTable
ns'
rCount
Nothing
getNodeNodeWith :: NodeId -> proxy a -> Maybe NodeType -> Cmd err [a]
getNodeNodeWith pId _ maybeNodeType = runOpaQuery query
where
query = selectChildren pId maybeNodeType
selectChildren :: ParentId
-> Maybe NodeType
-> Query NodeRead
selectChildren parentId maybeNodeType = proc () -> do
row@(Node nId typeName _ parent_id _ _ _) <- queryNodeTable -< ()
(NodeNode _ n1id n2id _ _) <- queryNodeNodeTable -< ()
let nodeType = maybe 0 nodeTypeId maybeNodeType
restrict -< typeName .== pgInt4 nodeType
restrict -< (.||) (parent_id .== (pgNodeId parentId))
( (.&&) (n1id .== pgNodeId parentId)
(n2id .== nId))
returnA -< row
-}
------------------------------------------------------------------------
insertNodeNode
::
[
NodeNode
]
->
Cmd
err
Int
insertNodeNode
ns
=
mkCmd
$
\
conn
->
fromIntegral
<$>
(
runInsert_
conn
$
Insert
nodeNodeTable
ns'
rCount
(
Just
DoNothing
))
where
where
ns'
::
[
NodeNodeWrite
]
ns'
::
[
NodeNodeWrite
]
ns'
=
map
(
\
(
NodeNode
n1
n2
x
y
)
ns'
=
map
(
\
(
NodeNode
n1
n2
x
y
)
...
@@ -83,6 +107,8 @@ insertNodeNode ns = mkCmd $ \conn -> runInsert_ conn
...
@@ -83,6 +107,8 @@ insertNodeNode ns = mkCmd $ \conn -> runInsert_ conn
(
pgInt4
<$>
y
)
(
pgInt4
<$>
y
)
)
ns
)
ns
------------------------------------------------------------------------
------------------------------------------------------------------------
type
Node1_Id
=
NodeId
type
Node1_Id
=
NodeId
type
Node2_Id
=
NodeId
type
Node2_Id
=
NodeId
...
...
src/Gargantext/Database/Schema/Ngrams.hs
View file @
1aa7eefa
...
@@ -42,7 +42,7 @@ type NgramsId = Int
...
@@ -42,7 +42,7 @@ type NgramsId = Int
type
NgramsTerms
=
Text
type
NgramsTerms
=
Text
type
Size
=
Int
type
Size
=
Int
data
NgramsPoly
id
terms
n
=
NgramsD
b
{
_ngrams_id
::
!
id
data
NgramsPoly
id
terms
n
=
NgramsD
B
{
_ngrams_id
::
!
id
,
_ngrams_terms
::
!
terms
,
_ngrams_terms
::
!
terms
,
_ngrams_n
::
!
n
,
_ngrams_n
::
!
n
}
deriving
(
Show
)
}
deriving
(
Show
)
...
@@ -59,14 +59,14 @@ type NgramsReadNull = NgramsPoly (Column (Nullable PGInt4))
...
@@ -59,14 +59,14 @@ type NgramsReadNull = NgramsPoly (Column (Nullable PGInt4))
(
Column
(
Nullable
PGText
))
(
Column
(
Nullable
PGText
))
(
Column
(
Nullable
PGInt4
))
(
Column
(
Nullable
PGInt4
))
type
NgramsD
b
=
NgramsPoly
Int
Text
Int
type
NgramsD
B
=
NgramsPoly
Int
Text
Int
$
(
makeAdaptorAndInstance
"pNgramsDb"
''
N
gramsPoly
)
$
(
makeAdaptorAndInstance
"pNgramsDb"
''
N
gramsPoly
)
makeLenses
''
N
gramsPoly
makeLenses
''
N
gramsPoly
ngramsTable
::
Table
NgramsWrite
NgramsRead
ngramsTable
::
Table
NgramsWrite
NgramsRead
ngramsTable
=
Table
"ngrams"
(
pNgramsDb
NgramsD
b
{
_ngrams_id
=
optional
"id"
ngramsTable
=
Table
"ngrams"
(
pNgramsDb
NgramsD
B
{
_ngrams_id
=
optional
"id"
,
_ngrams_terms
=
required
"terms"
,
_ngrams_terms
=
required
"terms"
,
_ngrams_n
=
required
"n"
,
_ngrams_n
=
required
"n"
}
}
...
...
src/Gargantext/Database/Schema/Node.hs
View file @
1aa7eefa
...
@@ -25,7 +25,6 @@ import Prelude hiding (null, id, map, sum)
...
@@ -25,7 +25,6 @@ import Prelude hiding (null, id, map, sum)
------------------------------------------------------------------------
------------------------------------------------------------------------
-- Main polymorphic Node definition
-- Main polymorphic Node definition
data
NodePoly
id
data
NodePoly
id
typename
typename
userId
userId
...
@@ -53,7 +52,6 @@ $(makeLenses ''NodePoly)
...
@@ -53,7 +52,6 @@ $(makeLenses ''NodePoly)
$
(
makeAdaptorAndInstance
"pNode"
''
N
odePoly
)
$
(
makeAdaptorAndInstance
"pNode"
''
N
odePoly
)
$
(
makeLensesWith
abbreviatedFields
''
N
odePoly
)
$
(
makeLensesWith
abbreviatedFields
''
N
odePoly
)
------------------------------------------------------------------------
nodeTable
::
Table
NodeWrite
NodeRead
nodeTable
::
Table
NodeWrite
NodeRead
nodeTable
=
Table
"nodes"
(
pNode
Node
{
_node_id
=
optional
"id"
nodeTable
=
Table
"nodes"
(
pNode
Node
{
_node_id
=
optional
"id"
,
_node_typename
=
required
"typename"
,
_node_typename
=
required
"typename"
...
...
src/Gargantext/Database/Schema/NodeNode.hs
View file @
1aa7eefa
...
@@ -54,7 +54,9 @@ $(makeAdaptorAndInstance "pNodeNode" ''NodeNodePoly)
...
@@ -54,7 +54,9 @@ $(makeAdaptorAndInstance "pNodeNode" ''NodeNodePoly)
makeLenses
''
N
odeNodePoly
makeLenses
''
N
odeNodePoly
nodeNodeTable
::
Table
NodeNodeWrite
NodeNodeRead
nodeNodeTable
::
Table
NodeNodeWrite
NodeNodeRead
nodeNodeTable
=
Table
"nodes_nodes"
(
pNodeNode
nodeNodeTable
=
Table
"nodes_nodes"
(
pNodeNode
NodeNode
{
_nn_node1_id
=
required
"node1_id"
NodeNode
{
_nn_node1_id
=
required
"node1_id"
,
_nn_node2_id
=
required
"node2_id"
,
_nn_node2_id
=
required
"node2_id"
,
_nn_score
=
optional
"score"
,
_nn_score
=
optional
"score"
...
@@ -62,8 +64,6 @@ nodeNodeTable = Table "nodes_nodes" (pNodeNode
...
@@ -62,8 +64,6 @@ nodeNodeTable = Table "nodes_nodes" (pNodeNode
}
}
)
)
instance
QueryRunnerColumnDefault
(
Nullable
PGInt4
)
Int
where
instance
QueryRunnerColumnDefault
(
Nullable
PGInt4
)
Int
where
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
queryRunnerColumnDefault
=
fieldQueryRunnerColumn
...
...
src/Gargantext/Database/Schema/Prelude.hs
View file @
1aa7eefa
...
@@ -37,7 +37,7 @@ import Data.Profunctor.Product.TH (makeAdaptorAndInstance)
...
@@ -37,7 +37,7 @@ import Data.Profunctor.Product.TH (makeAdaptorAndInstance)
import
Data.Swagger
hiding
(
required
,
in_
)
import
Data.Swagger
hiding
(
required
,
in_
)
import
GHC.Generics
(
Generic
)
import
GHC.Generics
(
Generic
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
)
import
Opaleye
hiding
(
FromField
)
import
Opaleye
hiding
(
FromField
,
readOnly
)
import
Opaleye.Internal.QueryArr
(
Query
)
import
Opaleye.Internal.QueryArr
(
Query
)
import
Test.QuickCheck.Arbitrary
import
Test.QuickCheck.Arbitrary
...
...
src/Gargantext/Prelude.hs
View file @
1aa7eefa
...
@@ -292,9 +292,6 @@ deviation = sqrt . variance
...
@@ -292,9 +292,6 @@ deviation = sqrt . variance
movingAverage
::
(
Eq
b
,
Fractional
b
)
=>
Int
->
[
b
]
->
[
b
]
movingAverage
::
(
Eq
b
,
Fractional
b
)
=>
Int
->
[
b
]
->
[
b
]
movingAverage
steps
xs
=
map
mean
$
chunkAlong
steps
1
xs
movingAverage
steps
xs
=
map
mean
$
chunkAlong
steps
1
xs
ma
::
[
Double
]
->
[
Double
]
ma
=
movingAverage
3
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
--- Map in Map = Map2
--- Map in Map = Map2
...
...
src/Gargantext/Prelude/Utils.hs
View file @
1aa7eefa
...
@@ -14,9 +14,6 @@ Portability : POSIX
...
@@ -14,9 +14,6 @@ Portability : POSIX
module
Gargantext.Prelude.Utils
module
Gargantext.Prelude.Utils
where
where
import
Prelude
(
String
)
import
Data.Set
(
Set
)
import
Data.List
(
foldl
)
import
Control.Lens
(
view
)
import
Control.Lens
(
view
)
import
Control.Monad.Random.Class
(
MonadRandom
)
import
Control.Monad.Random.Class
(
MonadRandom
)
import
Control.Monad.Reader
(
MonadReader
)
import
Control.Monad.Reader
(
MonadReader
)
...
@@ -26,11 +23,9 @@ import GHC.IO (FilePath)
...
@@ -26,11 +23,9 @@ import GHC.IO (FilePath)
import
Gargantext.API.Admin.Settings
import
Gargantext.API.Admin.Settings
import
Gargantext.Database.Admin.Types.Node
(
NodeId
,
NodeType
)
import
Gargantext.Database.Admin.Types.Node
(
NodeId
,
NodeType
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Core.Crypto.Hash
import
System.Directory
(
createDirectoryIfMissing
)
import
System.Directory
(
createDirectoryIfMissing
)
import
System.Random
(
newStdGen
)
import
System.Random
(
newStdGen
)
import
qualified
Data.ByteString.Lazy.Char8
as
Char
import
qualified
Data.Digest.Pure.SHA
as
SHA
(
sha256
,
showDigest
)
import
qualified
Data.Set
as
Set
import
qualified
Data.Text
as
Text
import
qualified
Data.Text
as
Text
import
qualified
System.Random.Shuffle
as
SRS
import
qualified
System.Random.Shuffle
as
SRS
...
@@ -38,34 +33,6 @@ import qualified System.Random.Shuffle as SRS
...
@@ -38,34 +33,6 @@ import qualified System.Random.Shuffle as SRS
shuffle
::
MonadRandom
m
=>
[
a
]
->
m
[
a
]
shuffle
::
MonadRandom
m
=>
[
a
]
->
m
[
a
]
shuffle
ns
=
SRS
.
shuffleM
ns
shuffle
ns
=
SRS
.
shuffleM
ns
--------------------------------------------------------------------------
-- | Use this datatype to keep traceability of hashes
-- TODO use newtype
type
Hash
=
Text
-- | Class to make hashes
class
IsHashable
a
where
hash
::
a
->
Hash
-- | Main API to hash text
-- using sha256 for now
instance
IsHashable
Char
.
ByteString
where
hash
=
Text
.
pack
.
SHA
.
showDigest
.
SHA
.
sha256
instance
{-# OVERLAPPING #-}
IsHashable
String
where
hash
=
hash
.
Char
.
pack
instance
IsHashable
Text
where
hash
=
hash
.
Text
.
unpack
instance
IsHashable
(
Set
Hash
)
where
hash
=
hash
.
foldl
(
<>
)
""
.
Set
.
toList
instance
{-# OVERLAPPABLE #-}
IsHashable
a
=>
IsHashable
[
a
]
where
hash
=
hash
.
Set
.
fromList
.
map
hash
--------------------------------------------------------------------------
--------------------------------------------------------------------------
data
NodeToHash
=
NodeToHash
{
nodeType
::
NodeType
data
NodeToHash
=
NodeToHash
{
nodeType
::
NodeType
,
nodeId
::
NodeId
,
nodeId
::
NodeId
...
...
stack.yaml
View file @
1aa7eefa
...
@@ -53,7 +53,7 @@ extra-deps:
...
@@ -53,7 +53,7 @@ extra-deps:
-
git
:
https://github.com/np/patches-map
-
git
:
https://github.com/np/patches-map
commit
:
8c6f38c4844ead53e664cf9c82ba461715dbe445
commit
:
8c6f38c4844ead53e664cf9c82ba461715dbe445
-
git
:
https://github.com/delanoe/haskell-opaleye.git
#- opaleye-0.6.7002.0
-
git
:
https://github.com/delanoe/haskell-opaleye.git
#- opaleye-0.6.7002.0
commit
:
53385de076be09f728a1b58c035a18e9ff9bcfd6
commit
:
63ee65d974e9d20eaaf17a2e83652175988cbb79
-
git
:
https://github.com/delanoe/hsparql.git
-
git
:
https://github.com/delanoe/hsparql.git
commit
:
308c74b71a1abb0a91546fa57d353131248e3a7f
commit
:
308c74b71a1abb0a91546fa57d353131248e3a7f
-
Unique-0.4.7.6@sha256:a1ff411f4d68c756e01e8d532fbe8e57f1ac77f2cc0ee8a999770be2bca185c5,2723
-
Unique-0.4.7.6@sha256:a1ff411f4d68c756e01e8d532fbe8e57f1ac77f2cc0ee8a999770be2bca185c5,2723
...
@@ -85,5 +85,5 @@ extra-deps:
...
@@ -85,5 +85,5 @@ extra-deps:
-
ghc-byteorder-4.11.0.0.10@sha256:5ee4a907279bfec27b0f9de7b8fba4cecfd34395a0235a7784494de70ad4e98f,1535
-
ghc-byteorder-4.11.0.0.10@sha256:5ee4a907279bfec27b0f9de7b8fba4cecfd34395a0235a7784494de70ad4e98f,1535
# Matrix Computation
# Matrix Computation
-
accelerate-1.2.0.1
-
accelerate-1.2.0.1
-
smtp-mail-0.2.0.0@sha256:b91c81f6dbb41a9ceee8c443385118684ecec55006b77f7d3c0e49cffd2468cf,1211
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