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
153
Issues
153
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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
e1dbfd70
Commit
e1dbfd70
authored
Aug 31, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[nodeStory] insert/update/delete state handling
This doesn't work with locks yet.
parent
9166bb01
Pipeline
#3129
passed with stage
in 93 minutes and 14 seconds
Changes
4
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
171 additions
and
89 deletions
+171
-89
0.0.6.1.sql
devops/postgres/upgrade/0.0.6.1.sql
+7
-0
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+0
-9
Tools.hs
src/Gargantext/API/Ngrams/Tools.hs
+14
-12
NodeStory.hs
src/Gargantext/Core/NodeStory.hs
+150
-68
No files found.
devops/postgres/upgrade/0.0.6.1.sql
View file @
e1dbfd70
-- Start a new transaction. In case data migration goes wrong, we are
-- back to our original table.
BEGIN
;
-- we will migrate data here
-- rename old table and create a new one
...
...
@@ -56,3 +60,6 @@ INSERT INTO public.node_stories
FROM
node_stories_old
CROSS
JOIN
jsonb_each
(
archive
->
'state'
->
'NgramsTerms'
)
AS
j
JOIN
ngrams
ON
terms
=
j
.
key
;
-- finally, write out the stuff
COMMIT
;
src/Gargantext/API/Ngrams.hs
View file @
e1dbfd70
...
...
@@ -259,15 +259,6 @@ setListNgrams listId ngramsType ns = do
saveNodeStory
currentVersion
::
HasNodeStory
env
err
m
=>
ListId
->
m
Version
currentVersion
listId
=
do
--nls <- getRepo [listId]
pool
<-
view
connPool
nls
<-
liftBase
$
getNodeStory
pool
listId
pure
$
nls
^.
unNodeStory
.
at
listId
.
_Just
.
a_version
newNgramsFromNgramsStatePatch
::
NgramsStatePatch'
->
[
Ngrams
]
newNgramsFromNgramsStatePatch
p
=
[
text2ngrams
(
unNgramsTerm
n
)
...
...
src/Gargantext/API/Ngrams/Tools.hs
View file @
e1dbfd70
...
...
@@ -19,6 +19,7 @@ import Control.Lens (_Just, (^.), at, view, At, Index, IxValue)
import
Control.Monad.Reader
import
Data.HashMap.Strict
(
HashMap
)
import
Data.Hashable
(
Hashable
)
import
Data.Pool
(
withResource
)
import
Data.Set
(
Set
)
import
Data.Validity
import
Gargantext.API.Ngrams.Types
...
...
@@ -202,15 +203,16 @@ migrateFromDirToDb :: (CmdM env err m, HasNodeStory env err m)
=>
m
()
migrateFromDirToDb
=
do
pool
<-
view
connPool
listIds
<-
liftBase
$
getNodesIdWithType
pool
NodeList
printDebug
"[migrateFromDirToDb] listIds"
listIds
(
NodeStory
nls
)
<-
NSF
.
getRepoReadConfig
listIds
printDebug
"[migrateFromDirToDb] nls"
nls
_
<-
mapM
(
\
(
nId
,
a
)
->
do
n
<-
liftBase
$
nodeExists
pool
nId
case
n
of
False
->
pure
()
True
->
liftBase
$
upsertNodeArchive
pool
nId
a
)
$
Map
.
toList
nls
--
_
<-
nodeStoryIncs
(
Just
$
NodeStory
nls
)
listIds
pure
()
withResource
pool
$
\
c
->
do
listIds
<-
liftBase
$
getNodesIdWithType
c
NodeList
printDebug
"[migrateFromDirToDb] listIds"
listIds
(
NodeStory
nls
)
<-
NSF
.
getRepoReadConfig
listIds
printDebug
"[migrateFromDirToDb] nls"
nls
_
<-
mapM
(
\
(
nId
,
a
)
->
do
n
<-
liftBase
$
nodeExists
c
nId
case
n
of
False
->
pure
()
True
->
liftBase
$
upsertNodeStories
c
nId
a
)
$
Map
.
toList
nls
--
_
<-
nodeStoryIncs
(
Just
$
NodeStory
nls
)
listIds
pure
()
src/Gargantext/Core/NodeStory.hs
View file @
e1dbfd70
This diff is collapsed.
Click to expand it.
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