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
24ef381d
Commit
24ef381d
authored
Jun 19, 2023
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Revert "Merge remote-tracking branch 'origin/201-dev-user-pubmed-api-key' into dev""
This reverts commit
a444cb30
.
parent
0d383903
Pipeline
#4226
failed with stages
in 44 minutes and 51 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
123 additions
and
50 deletions
+123
-50
GraphQL.hs
src/Gargantext/API/GraphQL.hs
+2
-0
Node.hs
src/Gargantext/API/GraphQL/Node.hs
+54
-10
New.hs
src/Gargantext/API/Node/Corpus/New.hs
+1
-1
Types.hs
src/Gargantext/API/Node/Corpus/Types.hs
+21
-24
Table.hs
src/Gargantext/API/Table.hs
+5
-5
Tools.hs
src/Gargantext/Core/Viz/Phylo/API/Tools.hs
+1
-1
Corpus.hs
src/Gargantext/Database/Admin/Types/Hyperdata/Corpus.hs
+13
-9
Node.hs
src/Gargantext/Database/Query/Table/Node.hs
+26
-0
No files found.
src/Gargantext/API/GraphQL.hs
View file @
24ef381d
...
@@ -76,6 +76,7 @@ data Query m
...
@@ -76,6 +76,7 @@ data Query m
,
job_logs
::
GQLAT
.
JobLogArgs
->
m
(
Map
Int
JobLog
)
,
job_logs
::
GQLAT
.
JobLogArgs
->
m
(
Map
Int
JobLog
)
,
languages
::
GQLNLP
.
LanguagesArgs
->
m
GQLNLP
.
LanguagesMap
,
languages
::
GQLNLP
.
LanguagesArgs
->
m
GQLNLP
.
LanguagesMap
,
nodes
::
GQLNode
.
NodeArgs
->
m
[
GQLNode
.
Node
]
,
nodes
::
GQLNode
.
NodeArgs
->
m
[
GQLNode
.
Node
]
,
nodes_corpus
::
GQLNode
.
CorpusArgs
->
m
[
GQLNode
.
Corpus
]
,
node_parent
::
GQLNode
.
NodeParentArgs
->
m
[
GQLNode
.
Node
]
,
node_parent
::
GQLNode
.
NodeParentArgs
->
m
[
GQLNode
.
Node
]
,
user_infos
::
GQLUserInfo
.
UserInfoArgs
->
m
[
GQLUserInfo
.
UserInfo
]
,
user_infos
::
GQLUserInfo
.
UserInfoArgs
->
m
[
GQLUserInfo
.
UserInfo
]
,
users
::
GQLUser
.
UserArgs
->
m
[
GQLUser
.
User
m
]
,
users
::
GQLUser
.
UserArgs
->
m
[
GQLUser
.
User
m
]
...
@@ -120,6 +121,7 @@ rootResolver =
...
@@ -120,6 +121,7 @@ rootResolver =
,
job_logs
=
GQLAT
.
resolveJobLogs
,
job_logs
=
GQLAT
.
resolveJobLogs
,
languages
=
GQLNLP
.
resolveLanguages
,
languages
=
GQLNLP
.
resolveLanguages
,
nodes
=
GQLNode
.
resolveNodes
,
nodes
=
GQLNode
.
resolveNodes
,
nodes_corpus
=
GQLNode
.
resolveNodesCorpus
,
node_parent
=
GQLNode
.
resolveNodeParent
,
node_parent
=
GQLNode
.
resolveNodeParent
,
user_infos
=
GQLUserInfo
.
resolveUserInfos
,
user_infos
=
GQLUserInfo
.
resolveUserInfos
,
users
=
GQLUser
.
resolveUsers
,
users
=
GQLUser
.
resolveUsers
...
...
src/Gargantext/API/GraphQL/Node.hs
View file @
24ef381d
...
@@ -3,7 +3,9 @@
...
@@ -3,7 +3,9 @@
module
Gargantext.API.GraphQL.Node
where
module
Gargantext.API.GraphQL.Node
where
import
Data.Aeson
import
Data.Either
(
Either
(
..
))
import
Data.Either
(
Either
(
..
))
import
qualified
Data.HashMap.Strict
as
HashMap
import
Data.Morpheus.Types
import
Data.Morpheus.Types
(
GQLType
(
GQLType
,
Resolver
,
Resolver
...
@@ -16,23 +18,37 @@ import Gargantext.API.Prelude (GargM, GargError)
...
@@ -16,23 +18,37 @@ import Gargantext.API.Prelude (GargM, GargError)
import
Gargantext.Database.Admin.Types.Node
(
NodeId
(
..
),
NodeType
)
import
Gargantext.Database.Admin.Types.Node
(
NodeId
(
..
),
NodeType
)
import
qualified
Gargantext.Database.Admin.Types.Node
as
NN
import
qualified
Gargantext.Database.Admin.Types.Node
as
NN
import
Gargantext.Database.Query.Table.Node
(
getClosestParentIdByType
,
getNode
)
import
Gargantext.Database.Query.Table.Node
(
getClosestParentIdByType
,
getNode
)
import
Gargantext.Database.Prelude
(
CmdCommon
)
import
Gargantext.Database.Prelude
(
CmdCommon
)
-- , JSONB)
import
qualified
Gargantext.Database.Schema.Node
as
N
import
qualified
Gargantext.Database.Schema.Node
as
N
import
Gargantext.Prelude
import
Gargantext.Prelude
import
GHC.Generics
(
Generic
)
import
GHC.Generics
(
Generic
)
import
qualified
Prelude
import
qualified
Prelude
import
qualified
PUBMED.Types
as
PUBMED
import
Text.Read
(
readEither
)
import
Text.Read
(
readEither
)
data
Corpus
=
Corpus
{
id
::
Int
,
name
::
Text
,
parent_id
::
Maybe
Int
,
pubmedAPIKey
::
Maybe
PUBMED
.
APIKey
,
type_id
::
Int
}
deriving
(
Show
,
Generic
,
GQLType
)
data
Node
=
Node
data
Node
=
Node
{
id
::
Int
{
id
::
Int
,
name
::
Text
,
name
::
Text
,
parent_id
::
Maybe
Int
,
parent_id
::
Maybe
Int
,
type_id
::
Int
,
type_id
::
Int
}
deriving
(
Show
,
Generic
,
GQLType
)
}
deriving
(
Show
,
Generic
,
GQLType
)
data
CorpusArgs
=
CorpusArgs
{
corpus_id
::
Int
}
deriving
(
Generic
,
GQLType
)
data
NodeArgs
data
NodeArgs
=
NodeArgs
=
NodeArgs
{
node_id
::
Int
{
node_id
::
Int
}
deriving
(
Generic
,
GQLType
)
}
deriving
(
Generic
,
GQLType
)
type
GqlM
e
env
=
Resolver
QUERY
e
(
GargM
env
GargError
)
type
GqlM
e
env
=
Resolver
QUERY
e
(
GargM
env
GargError
)
...
@@ -43,6 +59,11 @@ resolveNodes
...
@@ -43,6 +59,11 @@ resolveNodes
=>
NodeArgs
->
GqlM
e
env
[
Node
]
=>
NodeArgs
->
GqlM
e
env
[
Node
]
resolveNodes
NodeArgs
{
node_id
}
=
dbNodes
node_id
resolveNodes
NodeArgs
{
node_id
}
=
dbNodes
node_id
resolveNodesCorpus
::
(
CmdCommon
env
)
=>
CorpusArgs
->
GqlM
e
env
[
Corpus
]
resolveNodesCorpus
CorpusArgs
{
corpus_id
}
=
dbNodesCorpus
corpus_id
dbNodes
dbNodes
::
(
CmdCommon
env
)
::
(
CmdCommon
env
)
=>
Int
->
GqlM
e
env
[
Node
]
=>
Int
->
GqlM
e
env
[
Node
]
...
@@ -50,6 +71,13 @@ dbNodes node_id = do
...
@@ -50,6 +71,13 @@ dbNodes node_id = do
node
<-
lift
$
getNode
$
NodeId
node_id
node
<-
lift
$
getNode
$
NodeId
node_id
pure
[
toNode
node
]
pure
[
toNode
node
]
dbNodesCorpus
::
(
CmdCommon
env
)
=>
Int
->
GqlM
e
env
[
Corpus
]
dbNodesCorpus
corpus_id
=
do
corpus
<-
lift
$
getNode
$
NodeId
corpus_id
pure
[
toCorpus
corpus
]
data
NodeParentArgs
data
NodeParentArgs
=
NodeParentArgs
=
NodeParentArgs
{
node_id
::
Int
{
node_id
::
Int
...
@@ -79,7 +107,23 @@ dbParentNodes node_id parent_type = do
...
@@ -79,7 +107,23 @@ dbParentNodes node_id parent_type = do
pure
[
toNode
node
]
pure
[
toNode
node
]
toNode
::
NN
.
Node
json
->
Node
toNode
::
NN
.
Node
json
->
Node
toNode
(
N
.
Node
{
..
})
=
Node
{
id
=
NN
.
unNodeId
_node_id
toNode
N
.
Node
{
..
}
=
Node
{
id
=
NN
.
unNodeId
_node_id
,
name
=
_node_name
,
name
=
_node_name
,
parent_id
=
NN
.
unNodeId
<$>
_node_parent_id
,
parent_id
=
NN
.
unNodeId
<$>
_node_parent_id
,
type_id
=
_node_typename
}
,
type_id
=
_node_typename
}
toCorpus
::
NN
.
Node
Value
->
Corpus
toCorpus
N
.
Node
{
..
}
=
Corpus
{
id
=
NN
.
unNodeId
_node_id
,
name
=
_node_name
,
parent_id
=
NN
.
unNodeId
<$>
_node_parent_id
,
pubmedAPIKey
=
pubmedAPIKeyFromValue
_node_hyperdata
,
type_id
=
_node_typename
}
pubmedAPIKeyFromValue
::
Value
->
Maybe
PUBMED
.
APIKey
pubmedAPIKeyFromValue
(
Object
kv
)
=
case
HashMap
.
lookup
"pubmed_api_key"
kv
of
Nothing
->
Nothing
Just
v
->
case
fromJSON
v
of
Error
_
->
Nothing
Success
v'
->
Just
v'
pubmedAPIKeyFromValue
_
=
Nothing
src/Gargantext/API/Node/Corpus/New.hs
View file @
24ef381d
...
@@ -56,7 +56,7 @@ import Gargantext.Database.Action.User (getUserId)
...
@@ -56,7 +56,7 @@ import Gargantext.Database.Action.User (getUserId)
import
Gargantext.Database.Admin.Types.Hyperdata
import
Gargantext.Database.Admin.Types.Hyperdata
import
Gargantext.Database.Admin.Types.Node
(
CorpusId
,
NodeType
(
..
))
import
Gargantext.Database.Admin.Types.Node
(
CorpusId
,
NodeType
(
..
))
import
Gargantext.Database.Prelude
(
hasConfig
)
import
Gargantext.Database.Prelude
(
hasConfig
)
import
Gargantext.Database.Query.Table.Node
(
getNodeWith
)
import
Gargantext.Database.Query.Table.Node
(
getNodeWith
,
updateCorpusPubmedAPIKey
)
import
Gargantext.Database.Query.Table.Node.UpdateOpaleye
(
updateHyperdata
)
import
Gargantext.Database.Query.Table.Node.UpdateOpaleye
(
updateHyperdata
)
import
Gargantext.Database.Schema.Node
(
node_hyperdata
)
import
Gargantext.Database.Schema.Node
(
node_hyperdata
)
import
Gargantext.Prelude
import
Gargantext.Prelude
...
...
src/Gargantext/API/Node/Corpus/Types.hs
View file @
24ef381d
...
@@ -3,18 +3,12 @@
...
@@ -3,18 +3,12 @@
module
Gargantext.API.Node.Corpus.Types
where
module
Gargantext.API.Node.Corpus.Types
where
import
Control.Lens
hiding
(
elements
,
Empty
)
import
Control.Lens
hiding
(
elements
,
Empty
)
import
Control.Monad.Fail
(
fail
)
import
Control.Monad.Reader
(
MonadReader
)
import
Data.Aeson
import
Data.Aeson
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Monoid
(
mempty
)
import
Data.Monoid
(
mempty
)
import
Data.Swagger
import
Data.Swagger
import
Data.Text
(
Text
)
import
qualified
Data.Text
as
T
import
GHC.Generics
(
Generic
)
import
GHC.Generics
(
Generic
)
import
Text.Regex.TDFA
((
=~
))
import
Protolude
((
++
))
import
Gargantext.Prelude
import
Gargantext.Prelude
import
qualified
Gargantext.API.Admin.Orchestrator.Types
as
Types
import
qualified
Gargantext.API.Admin.Orchestrator.Types
as
Types
...
@@ -30,7 +24,8 @@ data Database = Empty
...
@@ -30,7 +24,8 @@ data Database = Empty
deriving
(
Eq
,
Show
,
Generic
,
Enum
,
Bounded
)
deriving
(
Eq
,
Show
,
Generic
,
Enum
,
Bounded
)
deriveJSON
(
unPrefix
""
)
''
D
atabase
deriveJSON
(
unPrefix
""
)
''
D
atabase
instance
ToSchema
Database
instance
ToSchema
Database
where
declareNamedSchema
=
genericDeclareNamedSchemaUnrestricted
defaultSchemaOptions
database2origin
::
Database
->
DataOrigin
database2origin
::
Database
->
DataOrigin
database2origin
Empty
=
InternalOrigin
Types
.
IsTex
database2origin
Empty
=
InternalOrigin
Types
.
IsTex
...
@@ -42,27 +37,29 @@ database2origin Isidore = ExternalOrigin Types.Isidore
...
@@ -42,27 +37,29 @@ database2origin Isidore = ExternalOrigin Types.Isidore
------------------------------------------------------------------------
------------------------------------------------------------------------
data
Datafield
=
Gargantext
data
Datafield
=
Gargantext
|
External
(
Maybe
Database
)
|
External
Database
|
Web
|
Web
|
Files
|
Files
deriving
(
Eq
,
Show
,
Generic
)
deriving
(
Eq
,
Show
,
Generic
)
instance
FromJSON
Datafield
where
instance
FromJSON
Datafield
parseJSON
=
withText
"Datafield"
$
\
text
->
instance
ToJSON
Datafield
case
text
of
-- instance FromJSON Datafield where
"Gargantext"
->
pure
Gargantext
-- parseJSON = withText "Datafield" $ \text ->
"Web"
->
pure
Web
-- case text of
"Files"
->
pure
Files
-- "Gargantext" -> pure Gargantext
v
->
-- "Web" -> pure Web
let
(
preExternal
,
_
,
postExternal
)
=
v
=~
(
"External "
::
Text
)
::
(
Text
,
Text
,
Text
)
-- "Files" -> pure Files
in
-- v ->
if
preExternal
==
""
then
do
-- let (preExternal, _, postExternal) = v =~ ("External " :: Text) :: (Text, Text, Text)
db
<-
parseJSON
$
String
postExternal
-- in
pure
$
External
db
-- if preExternal == "" then do
else
fail
$
"Cannot match patterh 'External <db>' for string "
++
(
T
.
unpack
v
)
-- db <- parseJSON $ String postExternal
instance
ToJSON
Datafield
where
-- pure $ External db
toJSON
(
External
db
)
=
toJSON
$
"External "
++
(
show
db
)
-- else fail $ "Cannot match patterh 'External <db>' for string " ++ (T.unpack v)
toJSON
s
=
toJSON
$
show
s
-- instance ToJSON Datafield where
-- toJSON (External db) = toJSON $ "External " ++ (show db)
-- toJSON s = toJSON $ show s
instance
ToSchema
Datafield
where
instance
ToSchema
Datafield
where
declareNamedSchema
_
=
do
declareNamedSchema
_
=
do
return
$
NamedSchema
(
Just
"Datafield"
)
$
mempty
return
$
NamedSchema
(
Just
"Datafield"
)
$
mempty
...
...
src/Gargantext/API/Table.hs
View file @
24ef381d
...
@@ -73,11 +73,11 @@ type TableApi = Summary "Table API"
...
@@ -73,11 +73,11 @@ type TableApi = Summary "Table API"
:>
Get
'[
J
SON
]
Text
:>
Get
'[
J
SON
]
Text
data
TableQuery
=
TableQuery
data
TableQuery
=
TableQuery
{
tq_offset
::
Offset
{
tq_offset
::
Offset
,
tq_limit
::
Limit
,
tq_limit
::
Limit
,
tq_orderBy
::
OrderBy
,
tq_orderBy
::
OrderBy
,
tq_view
::
TabType
,
tq_view
::
TabType
,
tq_query
::
Text
,
tq_query
::
Text
}
deriving
(
Generic
)
}
deriving
(
Generic
)
type
FacetTableResult
=
TableResult
FacetDoc
type
FacetTableResult
=
TableResult
FacetDoc
...
...
src/Gargantext/Core/Viz/Phylo/API/Tools.hs
View file @
24ef381d
...
@@ -12,10 +12,10 @@ Portability : POSIX
...
@@ -12,10 +12,10 @@ Portability : POSIX
module
Gargantext.Core.Viz.Phylo.API.Tools
module
Gargantext.Core.Viz.Phylo.API.Tools
where
where
import
Data.Proxy
import
Data.Aeson
(
Value
,
decodeFileStrict
,
eitherDecode
,
encode
)
import
Data.Aeson
(
Value
,
decodeFileStrict
,
eitherDecode
,
encode
)
import
Data.Map.Strict
(
Map
)
import
Data.Map.Strict
(
Map
)
import
Data.Maybe
(
catMaybes
)
import
Data.Maybe
(
catMaybes
)
import
Data.Proxy
import
Data.Set
(
Set
)
import
Data.Set
(
Set
)
import
Data.Text
(
Text
,
pack
)
import
Data.Text
(
Text
,
pack
)
import
Data.Time.Calendar
(
fromGregorian
,
diffGregorianDurationClip
,
cdMonths
,
diffDays
,
showGregorian
)
import
Data.Time.Calendar
(
fromGregorian
,
diffGregorianDurationClip
,
cdMonths
,
diffDays
,
showGregorian
)
...
...
src/Gargantext/Database/Admin/Types/Hyperdata/Corpus.hs
View file @
24ef381d
...
@@ -24,22 +24,26 @@ module Gargantext.Database.Admin.Types.Hyperdata.Corpus
...
@@ -24,22 +24,26 @@ module Gargantext.Database.Admin.Types.Hyperdata.Corpus
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Database.Admin.Types.Hyperdata.CorpusField
import
Gargantext.Database.Admin.Types.Hyperdata.CorpusField
import
Gargantext.Database.Admin.Types.Hyperdata.Prelude
import
Gargantext.Database.Admin.Types.Hyperdata.Prelude
import
PUBMED.Types
(
APIKey
)
------------------------------------------------------------------------
------------------------------------------------------------------------
data
HyperdataCorpus
=
data
HyperdataCorpus
=
HyperdataCorpus
{
_hc_fields
::
!
[
HyperdataField
CorpusField
]
}
HyperdataCorpus
{
_hc_fields
::
!
[
HyperdataField
CorpusField
]
,
_hc_pubmed_api_key
::
Maybe
APIKey
}
deriving
(
Generic
)
deriving
(
Generic
)
defaultHyperdataCorpus
::
HyperdataCorpus
defaultHyperdataCorpus
::
HyperdataCorpus
defaultHyperdataCorpus
=
defaultHyperdataCorpus
=
HyperdataCorpus
[
HyperdataField
Markdown
HyperdataCorpus
"Corpus analysis"
{
_hc_fields
=
[
HyperdataField
Markdown
(
MarkdownField
"# title
\n
## subtitle"
)
"Corpus analysis"
(
MarkdownField
"# title
\n
## subtitle"
)
,
HyperdataField
JSON
"Metadata (Experts only)"
,
HyperdataField
JSON
(
JsonField
"Title"
"Descr"
"Bool query"
"Authors"
)
"Metadata (Experts only)"
]
(
JsonField
"Title"
"Descr"
"Bool query"
"Authors"
)
]
,
_hc_pubmed_api_key
=
Nothing
}
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
...
...
src/Gargantext/Database/Query/Table/Node.hs
View file @
24ef381d
...
@@ -29,6 +29,7 @@ import Data.Text (Text)
...
@@ -29,6 +29,7 @@ import Data.Text (Text)
import
Database.PostgreSQL.Simple.SqlQQ
(
sql
)
import
Database.PostgreSQL.Simple.SqlQQ
(
sql
)
import
Opaleye
hiding
(
FromField
)
import
Opaleye
hiding
(
FromField
)
import
Prelude
hiding
(
null
,
id
,
map
,
sum
)
import
Prelude
hiding
(
null
,
id
,
map
,
sum
)
import
qualified
PUBMED.Types
as
PUBMED
import
Gargantext.Core
import
Gargantext.Core
import
Gargantext.Core.Types
import
Gargantext.Core.Types
...
@@ -327,6 +328,31 @@ insertNodesWithParent pid ns = insertNodes (set node_parent_id (pgNodeId <$> pid
...
@@ -327,6 +328,31 @@ insertNodesWithParent pid ns = insertNodes (set node_parent_id (pgNodeId <$> pid
insertNodesWithParentR
::
Maybe
ParentId
->
[
NodeWrite
]
->
Cmd
err
[
NodeId
]
insertNodesWithParentR
::
Maybe
ParentId
->
[
NodeWrite
]
->
Cmd
err
[
NodeId
]
insertNodesWithParentR
pid
ns
=
insertNodesR
(
set
node_parent_id
(
pgNodeId
<$>
pid
)
<$>
ns
)
insertNodesWithParentR
pid
ns
=
insertNodesR
(
set
node_parent_id
(
pgNodeId
<$>
pid
)
<$>
ns
)
getCorpusPubmedAPIKey
::
NodeId
->
Cmd
err
(
Maybe
PUBMED
.
APIKey
)
getCorpusPubmedAPIKey
cId
=
do
res
<-
runPGSQuery
query
params
pure
$
(
\
(
PGS
.
Only
apiKey
)
->
apiKey
)
<$>
head
res
where
query
::
PGS
.
Query
query
=
[
sql
|
SELECT hyperdata -> 'pubmed_api_key'
FROM nodes
WHERE id = ?
|]
params
=
PGS
.
Only
cId
updateCorpusPubmedAPIKey
::
NodeId
->
PUBMED
.
APIKey
->
Cmd
err
Int64
updateCorpusPubmedAPIKey
cId
apiKey
=
execPGSQuery
query
params
where
query
::
PGS
.
Query
query
=
[
sql
|
UPDATE nodes
SET hyperdata = hyperdata || ?
WHERE id = ?
|]
params
=
(
encode
$
object
[
"pubmed_api_key"
.=
apiKey
],
cId
)
------------------------------------------------------------------------
------------------------------------------------------------------------
-- TODO
-- TODO
-- currently this function removes the child relation
-- currently this function removes the child relation
...
...
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