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
199
Issues
199
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
d57cfce1
Commit
d57cfce1
authored
Dec 19, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[nodeStory] fixNodeStoryVersions command
parent
d18e6db2
Pipeline
#3485
passed with stage
in 92 minutes and 41 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
6 deletions
+46
-6
Main.hs
bin/gargantext-import/Main.hs
+1
-1
NodeStory.hs
src/Gargantext/Core/NodeStory.hs
+44
-1
Prelude.hs
src/Gargantext/Database/Schema/Prelude.hs
+1
-2
Types.hs
src/Gargantext/Database/Types.hs
+0
-2
No files found.
bin/gargantext-import/Main.hs
View file @
d57cfce1
...
@@ -78,7 +78,7 @@ main = do
...
@@ -78,7 +78,7 @@ main = do
_
<-
if
fun
==
"corpusCsvHal"
_
<-
if
fun
==
"corpusCsvHal"
then
runCmdDev
env
corpusCsvHal
then
runCmdDev
env
corpusCsvHal
else
pure
0
--(cs "false")
else
pure
0
--(cs "false")
_
<-
if
fun
==
"annuaire"
_
<-
if
fun
==
"annuaire"
then
runCmdDev
env
annuaire
then
runCmdDev
env
annuaire
else
pure
0
else
pure
0
...
...
src/Gargantext/Core/NodeStory.hs
View file @
d57cfce1
...
@@ -88,7 +88,8 @@ module Gargantext.Core.NodeStory
...
@@ -88,7 +88,8 @@ module Gargantext.Core.NodeStory
,
nodeStoriesQuery
,
nodeStoriesQuery
,
currentVersion
,
currentVersion
,
archiveStateFromList
,
archiveStateFromList
,
archiveStateToList
)
,
archiveStateToList
,
fixNodeStoryVersions
)
where
where
-- import Debug.Trace (traceShow)
-- import Debug.Trace (traceShow)
...
@@ -719,3 +720,45 @@ currentVersion listId = do
...
@@ -719,3 +720,45 @@ currentVersion listId = do
-----------------------------------------
-----------------------------------------
fixNodeStoryVersions
::
(
HasNodeStory
env
err
m
)
=>
m
()
fixNodeStoryVersions
=
do
pool
<-
view
connPool
_
<-
withResource
pool
$
\
c
->
liftBase
$
PGS
.
withTransaction
c
$
do
nIds
<-
runPGSQuery
c
[
sql
|
SELECT id FROM nodes WHERE ?
|]
(
PGS
.
Only
True
)
::
IO
[
PGS
.
Only
Int64
]
printDebug
"[fixNodeStoryVersions] nIds"
nIds
_
<-
mapM_
(
\
(
PGS
.
Only
nId
)
->
do
printDebug
"[fixNodeStoryVersions] nId"
nId
updateVer
c
TableNgrams
.
Authors
nId
updateVer
c
TableNgrams
.
Institutes
nId
updateVer
c
TableNgrams
.
Sources
nId
updateVer
c
TableNgrams
.
NgramsTerms
nId
pure
()
)
nIds
pure
()
pure
()
where
maxVerQuery
::
PGS
.
Query
maxVerQuery
=
[
sql
|
SELECT max(version)
FROM node_stories
WHERE node_id = ?
AND ngrams_type_id = ?
|]
updateVerQuery
::
PGS
.
Query
updateVerQuery
=
[
sql
|
UPDATE node_stories
SET version = ?
WHERE node_id = ?
AND ngrams_type_id = ?
|]
updateVer
::
PGS
.
Connection
->
TableNgrams
.
NgramsType
->
Int64
->
IO
()
updateVer
c
ngramsType
nId
=
do
maxVer
<-
runPGSQuery
c
maxVerQuery
(
nId
,
ngramsType
)
::
IO
[
PGS
.
Only
(
Maybe
Int64
)]
case
maxVer
of
[]
->
pure
()
[
PGS
.
Only
Nothing
]
->
pure
()
[
PGS
.
Only
(
Just
maxVersion
)]
->
do
_
<-
runPGSExecute
c
updateVerQuery
(
maxVersion
,
nId
,
ngramsType
)
pure
()
_
->
panic
"Should get only 1 result!"
src/Gargantext/Database/Schema/Prelude.hs
View file @
d57cfce1
{-|
{-|
Module : Gargantext.Database.Prelude
Module : Gargantext.Database.Prelude
Description :
Description :
Copyright : (c) CNRS, 2017-Present
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Maintainer : team@gargantext.org
...
@@ -49,4 +49,3 @@ import Database.PostgreSQL.Simple.SqlQQ (sql)
...
@@ -49,4 +49,3 @@ import Database.PostgreSQL.Simple.SqlQQ (sql)
import
Database.PostgreSQL.Simple.ToField
(
toField
,
ToField
)
import
Database.PostgreSQL.Simple.ToField
(
toField
,
ToField
)
import
Database.PostgreSQL.Simple.ToRow
(
toRow
)
import
Database.PostgreSQL.Simple.ToRow
(
toRow
)
import
Database.PostgreSQL.Simple.Types
(
Values
(
..
),
QualifiedIdentifier
(
..
))
import
Database.PostgreSQL.Simple.Types
(
Values
(
..
),
QualifiedIdentifier
(
..
))
src/Gargantext/Database/Types.hs
View file @
d57cfce1
...
@@ -60,5 +60,3 @@ instance DefaultFromField SqlInt4 (Maybe Int) where
...
@@ -60,5 +60,3 @@ instance DefaultFromField SqlInt4 (Maybe Int) where
instance
DefaultFromField
(
Nullable
SqlText
)
Text
where
instance
DefaultFromField
(
Nullable
SqlText
)
Text
where
defaultFromField
=
fromPGSFromField
defaultFromField
=
fromPGSFromField
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