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
160
Issues
160
List
Board
Labels
Milestones
Merge Requests
14
Merge Requests
14
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
a243b95f
Commit
a243b95f
authored
Sep 08, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[nodeStory] add version to node_story_archive_history
This is so that we correctly order _a_history later.
parent
a7be6271
Pipeline
#3152
passed with stage
in 91 minutes and 46 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
12 deletions
+17
-12
schema.sql
devops/postgres/schema.sql
+1
-0
0.0.6.2.sql
devops/postgres/upgrade/0.0.6.2.sql
+2
-0
gargantext.cabal
gargantext.cabal
+4
-3
NodeStory.hs
src/Gargantext/Core/NodeStory.hs
+10
-9
No files found.
devops/postgres/schema.sql
View file @
a243b95f
...
...
@@ -244,6 +244,7 @@ create table public.node_story_archive_history (
ngrams_type_id
INTEGER
NOT
NULL
,
ngrams_id
INTEGER
NOT
NULL
,
patch
jsonb
DEFAULT
'{}'
::
jsonb
NOT
NULL
,
version
INTEGER
NOT
NULL
DEFAULT
0
,
PRIMARY
KEY
(
id
),
FOREIGN
KEY
(
node_id
)
REFERENCES
public
.
nodes
(
id
)
ON
DELETE
CASCADE
,
FOREIGN
KEY
(
ngrams_id
)
REFERENCES
public
.
ngrams
(
id
)
ON
DELETE
CASCADE
...
...
devops/postgres/upgrade/0.0.6.2.sql
0 → 100644
View file @
a243b95f
ALTER
TABLE
node_story_archive_history
ADD
COLUMN
version
INTEGER
NOT
NULL
DEFAULT
0
;
gargantext.cabal
View file @
a243b95f
...
...
@@ -5,7 +5,7 @@ cabal-version: 1.12
-- see: https://github.com/sol/hpack
name: gargantext
version: 0.0.6
version: 0.0.6
.1
synopsis: Search, map, share
description: Please see README.md
category: Data
...
...
@@ -51,6 +51,7 @@ library
Gargantext.Core.Types.Individu
Gargantext.Core.Types.Main
Gargantext.Core.Utils.Prefix
Gargantext.Utils.SpacyNLP
Gargantext.Database.Action.Flow
Gargantext.Database.Action.Flow.Types
Gargantext.Database.Action.User.New
...
...
@@ -76,6 +77,7 @@ library
Gargantext.Core.Text.Metrics.TFICF
Gargantext.Core.Text.Metrics.CharByChar
Gargantext.Core.Text.Metrics.Count
Gargantext.Core.Text.Prepare
Gargantext.Core.Text.Search
Gargantext.Core.Text.Terms
Gargantext.Core.Text.Terms.Mono
...
...
@@ -316,7 +318,6 @@ library
Gargantext.Database.Types
Gargantext.Utils.Aeson
Gargantext.Utils.JohnSnowNLP
Gargantext.Utils.SpacyNLP
Gargantext.Utils.Servant
Gargantext.Utils.UTCTime
Paths_gargantext
...
...
@@ -491,9 +492,9 @@ library
, transformers-base
, tuple
, unordered-containers
, uri-encode
, utf8-string
, uuid
, uri-encode
, validity
, vector
, wai
...
...
src/Gargantext/Core/NodeStory.hs
View file @
a243b95f
...
...
@@ -346,7 +346,7 @@ getNodesIdWithType c nt = do
-- nodeStorySelect :: Select NodeStoryRead
-- nodeStorySelect = selectTable nodeStoryTable
--
TODO Check ordering,
"first patch in the _a_history list is the most recent"
--
NOTE
"first patch in the _a_history list is the most recent"
getNodeArchiveHistory
::
PGS
.
Connection
->
NodeId
->
IO
[
NgramsStatePatch'
]
getNodeArchiveHistory
c
nodeId
=
do
as
<-
runPGSQuery
c
query
(
PGS
.
Only
nodeId
)
::
IO
[(
TableNgrams
.
NgramsType
,
NgramsTerm
,
NgramsPatch
)]
...
...
@@ -356,15 +356,16 @@ getNodeArchiveHistory c nodeId = do
query
=
[
sql
|
SELECT ngrams_type_id, terms, patch
FROM node_story_archive_history
JOIN ngrams ON ngrams.id = ngrams_id
WHERE node_id = ?
|]
WHERE node_id = ?
ORDER BY version DESC
|]
ngramsIdQuery
::
PGS
.
Query
ngramsIdQuery
=
[
sql
|
SELECT id FROM ngrams WHERE terms = ?
|]
insertNodeArchiveHistory
::
PGS
.
Connection
->
NodeId
->
[
NgramsStatePatch'
]
->
IO
()
insertNodeArchiveHistory
_
_
[]
=
pure
()
insertNodeArchiveHistory
c
nodeId
(
h
:
hs
)
=
do
insertNodeArchiveHistory
::
PGS
.
Connection
->
NodeId
->
Version
->
[
NgramsStatePatch'
]
->
IO
()
insertNodeArchiveHistory
_
_
_
[]
=
pure
()
insertNodeArchiveHistory
c
nodeId
version
(
h
:
hs
)
=
do
let
tuples
=
mconcat
$
(
\
(
nType
,
(
NgramsTablePatch
patch
))
->
(
\
(
term
,
p
)
->
(
nodeId
,
nType
,
term
,
p
))
<$>
PM
.
toList
patch
)
<$>
PM
.
toList
h
::
[(
NodeId
,
TableNgrams
.
NgramsType
,
NgramsTerm
,
NgramsPatch
)]
...
...
@@ -372,13 +373,13 @@ insertNodeArchiveHistory c nodeId (h:hs) = do
ngrams
<-
runPGSQuery
c
ngramsIdQuery
(
PGS
.
Only
term
)
pure
$
(
\
(
PGS
.
Only
termId
)
->
(
nId
,
nType
,
termId
,
term
,
patch
))
<$>
(
headMay
ngrams
)
)
tuples
::
IO
[
Maybe
(
NodeId
,
TableNgrams
.
NgramsType
,
Int
,
NgramsTerm
,
NgramsPatch
)]
_
<-
runPGSExecuteMany
c
query
$
((
\
(
nId
,
nType
,
termId
,
_term
,
patch
)
->
(
nId
,
nType
,
termId
,
patch
))
<$>
(
catMaybes
tuplesM
))
_
<-
insertNodeArchiveHistory
c
nodeId
hs
_
<-
runPGSExecuteMany
c
query
$
((
\
(
nId
,
nType
,
termId
,
_term
,
patch
)
->
(
nId
,
nType
,
termId
,
patch
,
version
))
<$>
(
catMaybes
tuplesM
))
_
<-
insertNodeArchiveHistory
c
nodeId
version
hs
pure
()
where
query
::
PGS
.
Query
query
=
[
sql
|
INSERT INTO node_story_archive_history(node_id, ngrams_type_id, ngrams_id, patch
) VALUES (
?, ?, ?, ?)
|]
query
=
[
sql
|
INSERT INTO node_story_archive_history(node_id, ngrams_type_id, ngrams_id, patch
, version) VALUES (?,
?, ?, ?, ?)
|]
getNodeStory
::
PGS
.
Connection
->
NodeId
->
IO
NodeListStory
getNodeStory
c
nId
@
(
NodeId
nodeId
)
=
do
...
...
@@ -540,7 +541,7 @@ upsertNodeStories c nodeId@(NodeId nId) newArchive = do
-- whether it's insert or update, we can insert node archive history already
-- NOTE: It is assumed that the most recent change is the first in the
-- list, so we save these in reverse order
insertNodeArchiveHistory
c
nodeId
$
reverse
$
newArchive
^.
a_history
insertNodeArchiveHistory
c
nodeId
(
newArchive
^.
a_version
)
$
reverse
$
newArchive
^.
a_history
(
NodeStory
m
)
<-
getNodeStory
c
nodeId
case
Map
.
lookup
nodeId
m
of
...
...
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