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
98fe47b6
Commit
98fe47b6
authored
Oct 05, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] gargantext-upgrade to update hyperdata of NodeList
parent
708cf038
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
113 additions
and
26 deletions
+113
-26
Main.hs
bin/gargantext-upgrade/Main.hs
+44
-0
package.yaml
package.yaml
+14
-0
Types.hs
src/Gargantext/API/Ngrams/Types.hs
+2
-0
Get.hs
src/Gargantext/API/Node/Get.hs
+1
-1
List.hs
src/Gargantext/Database/Admin/Types/Hyperdata/List.hs
+23
-15
Prelude.hs
src/Gargantext/Database/Prelude.hs
+3
-1
Node.hs
src/Gargantext/Database/Query/Table/Node.hs
+12
-5
Children.hs
src/Gargantext/Database/Query/Table/Node/Children.hs
+0
-1
UpdateOpaleye.hs
src/Gargantext/Database/Query/Table/Node/UpdateOpaleye.hs
+14
-3
No files found.
bin/gargantext-upgrade/Main.hs
0 → 100644
View file @
98fe47b6
{-|
Module : Main.hs
Description : Gargantext Import Corpus
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
Import a corpus binary.
-}
{-# LANGUAGE Strict #-}
module
Main
where
import
Data.Proxy
import
Gargantext.API.Admin.Settings
(
withDevEnv
,
runCmdDev
)
import
Gargantext.API.Prelude
(
GargError
)
import
Gargantext.API.Node
()
-- instances only
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Hyperdata
import
Gargantext.Database.Query.Table.Node.UpdateOpaleye
import
Gargantext.Database.Prelude
(
Cmd
,
)
import
Gargantext.Prelude
import
System.Environment
(
getArgs
)
main
::
IO
()
main
=
do
[
iniPath
]
<-
getArgs
let
updateNodes
::
Cmd
GargError
[
Int64
]
updateNodes
=
updateNodesWithType
NodeList
(
Proxy
::
Proxy
HyperdataList
)
(
\
_
->
defaultHyperdataList
)
withDevEnv
iniPath
$
\
env
->
do
x
<-
runCmdDev
env
updateNodes
putStrLn
$
show
x
pure
()
package.yaml
View file @
98fe47b6
...
@@ -55,6 +55,7 @@ library:
...
@@ -55,6 +55,7 @@ library:
-
Gargantext.Database.Action.Flow
-
Gargantext.Database.Action.Flow
-
Gargantext.Database.Query.Table.User
-
Gargantext.Database.Query.Table.User
-
Gargantext.Database.Query.Table.Node
-
Gargantext.Database.Query.Table.Node
-
Gargantext.Database.Query.Table.Node.UpdateOpaleye
-
Gargantext.Database.Prelude
-
Gargantext.Database.Prelude
-
Gargantext.Database.Admin.Trigger.Init
-
Gargantext.Database.Admin.Trigger.Init
-
Gargantext.Database.Admin.Config
-
Gargantext.Database.Admin.Config
...
@@ -383,6 +384,19 @@ executables:
...
@@ -383,6 +384,19 @@ executables:
-
gargantext
-
gargantext
-
base
-
base
gargantext-upgrade
:
main
:
Main.hs
source-dirs
:
bin/gargantext-upgrade
ghc-options
:
-
-threaded
-
-rtsopts
-
-with-rtsopts=-N
-
-O2
-
-Wmissing-signatures
dependencies
:
-
gargantext
-
base
gargantext-cbor2json
:
gargantext-cbor2json
:
main
:
Main.hs
main
:
Main.hs
source-dirs
:
bin/gargantext-cbor2json
source-dirs
:
bin/gargantext-cbor2json
...
...
src/Gargantext/API/Ngrams/Types.hs
View file @
98fe47b6
...
@@ -76,6 +76,7 @@ instance FromHttpApiData TabType
...
@@ -76,6 +76,7 @@ instance FromHttpApiData TabType
parseUrlPiece
"Contacts"
=
pure
Contacts
parseUrlPiece
"Contacts"
=
pure
Contacts
parseUrlPiece
_
=
Left
"Unexpected value of TabType"
parseUrlPiece
_
=
Left
"Unexpected value of TabType"
instance
ToParamSchema
TabType
instance
ToParamSchema
TabType
instance
ToJSON
TabType
instance
ToJSON
TabType
instance
FromJSON
TabType
instance
FromJSON
TabType
...
@@ -83,6 +84,7 @@ instance ToSchema TabType
...
@@ -83,6 +84,7 @@ instance ToSchema TabType
instance
Arbitrary
TabType
instance
Arbitrary
TabType
where
where
arbitrary
=
elements
[
minBound
..
maxBound
]
arbitrary
=
elements
[
minBound
..
maxBound
]
instance
FromJSONKey
TabType
where
instance
FromJSONKey
TabType
where
fromJSONKey
=
genericFromJSONKey
defaultJSONKeyOptions
fromJSONKey
=
genericFromJSONKey
defaultJSONKeyOptions
instance
ToJSONKey
TabType
where
instance
ToJSONKey
TabType
where
...
...
src/Gargantext/API/Node/Get.hs
View file @
98fe47b6
...
@@ -30,7 +30,7 @@ import Test.QuickCheck.Arbitrary
...
@@ -30,7 +30,7 @@ import Test.QuickCheck.Arbitrary
import
Gargantext.API.Prelude
import
Gargantext.API.Prelude
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.
Query.Table.No
de
(
JSONB
{-, getNodeWith-}
)
import
Gargantext.Database.
Prelu
de
(
JSONB
{-, getNodeWith-}
)
import
Gargantext.Prelude
import
Gargantext.Prelude
------------------------------------------------------------------------
------------------------------------------------------------------------
...
...
src/Gargantext/Database/Admin/Types/Hyperdata/List.hs
View file @
98fe47b6
...
@@ -23,7 +23,7 @@ module Gargantext.Database.Admin.Types.Hyperdata.List
...
@@ -23,7 +23,7 @@ module Gargantext.Database.Admin.Types.Hyperdata.List
import
Data.Map
(
Map
)
import
Data.Map
(
Map
)
import
qualified
Data.Map
as
Map
import
qualified
Data.Map
as
Map
import
Control.Applicative
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Core.Viz.Types
(
Histo
(
..
))
import
Gargantext.Core.Viz.Types
(
Histo
(
..
))
import
Gargantext.API.Ngrams.NTree
(
MyTree
)
import
Gargantext.API.Ngrams.NTree
(
MyTree
)
...
@@ -47,14 +47,24 @@ data HyperdataList =
...
@@ -47,14 +47,24 @@ data HyperdataList =
-- } deriving (Show, Generic)
-- } deriving (Show, Generic)
defaultHyperdataList
::
HyperdataList
defaultHyperdataList
::
HyperdataList
defaultHyperdataList
=
HyperdataList
{
defaultHyperdataList
=
_hl_chart
=
Map
.
empty
HyperdataList
{
_hl_chart
=
Map
.
empty
,
_hl_list
=
Nothing
,
_hl_list
=
Nothing
,
_hl_pie
=
Map
.
empty
,
_hl_pie
=
Map
.
empty
,
_hl_scatter
=
Map
.
empty
,
_hl_scatter
=
Map
.
empty
,
_hl_tree
=
Map
.
empty
,
_hl_tree
=
Map
.
empty
}
}
------------------------------------------------------------------------
-- Instances
------------------------------------------------------------------------
instance
Hyperdata
HyperdataList
$
(
makeLenses
''
H
yperdataList
)
$
(
deriveJSON
(
unPrefix
"_hl_"
)
''
H
yperdataList
)
------------------------------------------------------------------------
data
HyperdataListCooc
=
data
HyperdataListCooc
=
HyperdataListCooc
{
_hlc_preferences
::
!
Text
}
HyperdataListCooc
{
_hlc_preferences
::
!
Text
}
deriving
(
Generic
)
deriving
(
Generic
)
...
@@ -62,17 +72,15 @@ data HyperdataListCooc =
...
@@ -62,17 +72,15 @@ data HyperdataListCooc =
defaultHyperdataListCooc
::
HyperdataListCooc
defaultHyperdataListCooc
::
HyperdataListCooc
defaultHyperdataListCooc
=
HyperdataListCooc
""
defaultHyperdataListCooc
=
HyperdataListCooc
""
------------------------------------------------------------------------
-- Instances
------------------------------------------------------------------------
instance
Hyperdata
HyperdataList
instance
Hyperdata
HyperdataListCooc
$
(
makeLenses
''
H
yperdataList
)
instance
Hyperdata
HyperdataListCooc
$
(
makeLenses
''
H
yperdataListCooc
)
$
(
makeLenses
''
H
yperdataListCooc
)
$
(
deriveJSON
(
unPrefix
"_hl_"
)
''
H
yperdataList
)
$
(
deriveJSON
(
unPrefix
"_hlc_"
)
''
H
yperdataListCooc
)
$
(
deriveJSON
(
unPrefix
"_hlc_"
)
''
H
yperdataListCooc
)
instance
Arbitrary
HyperdataList
where
instance
Arbitrary
HyperdataList
where
arbitrary
=
pure
defaultHyperdataList
arbitrary
=
pure
defaultHyperdataList
instance
Arbitrary
HyperdataListCooc
where
instance
Arbitrary
HyperdataListCooc
where
...
...
src/Gargantext/Database/Prelude.hs
View file @
98fe47b6
...
@@ -30,7 +30,7 @@ import Data.Word (Word16)
...
@@ -30,7 +30,7 @@ import Data.Word (Word16)
import
Database.PostgreSQL.Simple
(
Connection
,
connect
)
import
Database.PostgreSQL.Simple
(
Connection
,
connect
)
import
Database.PostgreSQL.Simple.FromField
(
Conversion
,
ResultError
(
ConversionFailed
),
fromField
,
returnError
)
import
Database.PostgreSQL.Simple.FromField
(
Conversion
,
ResultError
(
ConversionFailed
),
fromField
,
returnError
)
import
Database.PostgreSQL.Simple.Internal
(
Field
)
import
Database.PostgreSQL.Simple.Internal
(
Field
)
import
Opaleye
(
Query
,
Unpackspec
,
showSqlForPostgres
,
FromFields
,
Select
,
runQuery
)
import
Opaleye
(
Query
,
Unpackspec
,
showSqlForPostgres
,
FromFields
,
Select
,
runQuery
,
PGJsonb
,
QueryRunnerColumnDefault
)
import
Opaleye.Aggregate
(
countRows
)
import
Opaleye.Aggregate
(
countRows
)
import
System.IO
(
FilePath
)
import
System.IO
(
FilePath
)
import
System.IO
(
stderr
)
import
System.IO
(
stderr
)
...
@@ -55,6 +55,8 @@ class HasConfig env where
...
@@ -55,6 +55,8 @@ class HasConfig env where
instance
HasConfig
GargConfig
where
instance
HasConfig
GargConfig
where
hasConfig
=
identity
hasConfig
=
identity
-------------------------------------------------------
type
JSONB
=
QueryRunnerColumnDefault
PGJsonb
-------------------------------------------------------
-------------------------------------------------------
type
CmdM'
env
err
m
=
type
CmdM'
env
err
m
=
(
MonadReader
env
m
(
MonadReader
env
m
...
...
src/Gargantext/Database/Query/Table/Node.hs
View file @
98fe47b6
...
@@ -99,7 +99,7 @@ getNodesWith parentId _ nodeType maybeOffset maybeLimit =
...
@@ -99,7 +99,7 @@ getNodesWith parentId _ nodeType maybeOffset maybeLimit =
-- TODO: Why is the second parameter ignored?
-- TODO: Why is the second parameter ignored?
-- TODO: Why not use getNodesWith?
-- TODO: Why not use getNodesWith?
getNodesWithParentId
::
(
Hyperdata
a
,
QueryRunnerColumnDefault
PGJsonb
a
)
getNodesWithParentId
::
(
Hyperdata
a
,
JSONB
a
)
=>
Maybe
NodeId
=>
Maybe
NodeId
->
Cmd
err
[
Node
a
]
->
Cmd
err
[
Node
a
]
getNodesWithParentId
n
=
runOpaQuery
$
selectNodesWithParentID
n'
getNodesWithParentId
n
=
runOpaQuery
$
selectNodesWithParentID
n'
...
@@ -154,13 +154,20 @@ selectNodesWithParentID n = proc () -> do
...
@@ -154,13 +154,20 @@ selectNodesWithParentID n = proc () -> do
restrict
-<
parent_id
.==
(
pgNodeId
n
)
restrict
-<
parent_id
.==
(
pgNodeId
n
)
returnA
-<
row
returnA
-<
row
selectNodesWithType
::
Column
PGInt4
->
Query
NodeRead
selectNodesWithType
type_id
=
proc
()
->
do
------------------------------------------------------------------------
-- | Example of use:
-- runCmdReplEasy (getNodesWithType NodeList (Proxy :: Proxy HyperdataList))
getNodesWithType
::
(
HasNodeError
err
,
JSONB
a
)
=>
NodeType
->
proxy
a
->
Cmd
err
[
Node
a
]
getNodesWithType
nt
_
=
runOpaQuery
$
selectNodesWithType
nt
selectNodesWithType
::
NodeType
->
Query
NodeRead
selectNodesWithType
nt
=
proc
()
->
do
row
@
(
Node
_
_
tn
_
_
_
_
_
)
<-
queryNodeTable
-<
()
row
@
(
Node
_
_
tn
_
_
_
_
_
)
<-
queryNodeTable
-<
()
restrict
-<
tn
.==
type_id
restrict
-<
tn
.==
(
pgInt4
$
nodeTypeId
nt
)
returnA
-<
row
returnA
-<
row
type
JSONB
=
QueryRunnerColumnDefault
PGJsonb
------------------------------------------------------------------------
getNode
::
HasNodeError
err
=>
NodeId
->
Cmd
err
(
Node
Value
)
getNode
::
HasNodeError
err
=>
NodeId
->
Cmd
err
(
Node
Value
)
...
...
src/Gargantext/Database/Query/Table/Node/Children.hs
View file @
98fe47b6
...
@@ -23,7 +23,6 @@ import Gargantext.Database.Admin.Config (nodeTypeId)
...
@@ -23,7 +23,6 @@ import Gargantext.Database.Admin.Config (nodeTypeId)
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataDocument
,
HyperdataContact
)
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataDocument
,
HyperdataContact
)
import
Gargantext.Database.Prelude
import
Gargantext.Database.Prelude
import
Gargantext.Database.Query.Filter
import
Gargantext.Database.Query.Filter
import
Gargantext.Database.Query.Table.Node
import
Gargantext.Database.Query.Table.NodeNode
import
Gargantext.Database.Query.Table.NodeNode
import
Gargantext.Database.Schema.Node
import
Gargantext.Database.Schema.Node
import
Opaleye
import
Opaleye
...
...
src/Gargantext/Database/Query/Table/Node/UpdateOpaleye.hs
View file @
98fe47b6
...
@@ -15,13 +15,14 @@ Portability : POSIX
...
@@ -15,13 +15,14 @@ Portability : POSIX
module
Gargantext.Database.Query.Table.Node.UpdateOpaleye
module
Gargantext.Database.Query.Table.Node.UpdateOpaleye
where
where
import
Opaleye
import
Opaleye
import
Data.Aeson
(
encode
,
ToJSON
)
import
Data.Aeson
(
encode
,
ToJSON
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Database.Schema.Node
import
Gargantext.Database.Schema.Node
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Prelude
(
Cmd
,
mkCmd
)
import
Gargantext.Database.Prelude
(
Cmd
,
mkCmd
,
JSONB
)
import
Gargantext.Database.Query.Table.Node
import
Gargantext.Database.Query.Table.Node.Error
updateHyperdata
::
ToJSON
a
=>
NodeId
->
a
->
Cmd
err
Int64
updateHyperdata
::
ToJSON
a
=>
NodeId
->
a
->
Cmd
err
Int64
updateHyperdata
i
h
=
mkCmd
$
\
c
->
runUpdate_
c
(
updateHyperdataQuery
i
h
)
updateHyperdata
i
h
=
mkCmd
$
\
c
->
runUpdate_
c
(
updateHyperdataQuery
i
h
)
...
@@ -37,3 +38,13 @@ updateHyperdataQuery i h = Update
...
@@ -37,3 +38,13 @@ updateHyperdataQuery i h = Update
}
}
where
h'
=
(
pgJSONB
$
cs
$
encode
$
h
)
where
h'
=
(
pgJSONB
$
cs
$
encode
$
h
)
----------------------------------------------------------------------------------
updateNodesWithType
::
(
HasNodeError
err
,
JSONB
a
,
ToJSON
a
)
=>
NodeType
->
proxy
a
->
(
a
->
a
)
->
Cmd
err
[
Int64
]
updateNodesWithType
nt
p
f
=
do
ns
<-
getNodesWithType
nt
p
mapM
(
\
n
->
updateHyperdata
(
_node_id
n
)
(
f
$
_node_hyperdata
n
))
ns
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