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
7
Merge Requests
7
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
d57a2246
Commit
d57a2246
authored
Apr 29, 2025
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP (refact HasNodeStoryEnv)
parent
ee0a337c
Pipeline
#7553
failed with stages
in 20 minutes and 55 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
74 deletions
+56
-74
Tools.hs
src/Gargantext/API/Ngrams/Tools.hs
+25
-38
Utils.hs
src/Gargantext/API/Node/Corpus/Export/Utils.hs
+7
-5
NodeStory.hs
src/Gargantext/Core/NodeStory.hs
+2
-2
Types.hs
src/Gargantext/Core/NodeStory/Types.hs
+6
-11
Update.hs
src/Gargantext/Database/Query/Table/Node/Update.hs
+16
-17
Example.hs
src/Gargantext/Database/Transactional/Example.hs
+0
-1
No files found.
src/Gargantext/API/Ngrams/Tools.hs
View file @
d57a2246
...
@@ -39,14 +39,8 @@ mergeNgramsElement _neOld neNew = neNew
...
@@ -39,14 +39,8 @@ mergeNgramsElement _neOld neNew = neNew
type
RootTerm
=
NgramsTerm
type
RootTerm
=
NgramsTerm
getRepo
::
HasNodeStory
env
err
m
getRepo
::
NodeStoryEnv
err
->
[
ListId
]
->
DBQuery
err
x
NodeListStory
=>
[
ListId
]
->
m
(
DBQuery
err
x
NodeListStory
)
getRepo
env
listIds
=
getNodeListStoryMulti
env
listIds
getRepo
listIds
=
do
f
<-
getNodeListStoryMulti
pure
$
f
listIds
-- v <- liftBase $ f listIds
-- v' <- liftBase $ atomically $ readTVar v
-- pure $ v'
repoSize
::
Ord
k1
=>
NodeStory
(
Map
.
Map
k1
(
Map
.
Map
k2
a
))
p
repoSize
::
Ord
k1
=>
NodeStory
(
Map
.
Map
k1
(
Map
.
Map
k2
a
))
p
...
@@ -59,27 +53,19 @@ repoSize repo node_id = Map.map Map.size state'
...
@@ -59,27 +53,19 @@ repoSize repo node_id = Map.map Map.size state'
.
a_state
.
a_state
getNodeStory
::
HasNodeStory
env
err
m
=>
ListId
->
m
(
DBQuery
err
x
ArchiveList
)
getNodeStory
::
NodeStoryEnv
err
->
ListId
->
DBQuery
err
x
ArchiveList
getNodeStory
l
=
do
getNodeStory
env
l
=
getNodeListStory
env
l
f
<-
getNodeListStory
pure
$
f
l
-- v <- liftBase $ f l
-- pure v
getNodeListStory
::
NodeStoryEnv
err
->
NodeId
->
DBQuery
err
x
ArchiveList
getNodeListStory
env
=
view
nse_getter
env
getNodeListStory
::
HasNodeStory
env
err
m
=>
m
(
NodeId
->
DBQuery
err
x
ArchiveList
)
getNodeListStory
=
do
env
<-
view
hasNodeStory
pure
$
view
nse_getter
env
getNodeListStoryMulti
::
HasNodeStory
env
err
m
=>
m
([
NodeId
]
->
DBQuery
err
x
NodeListStory
)
getNodeListStoryMulti
=
do
env
<-
view
hasNodeStory
pure
$
view
nse_getter_multi
env
getNodeListStoryMulti
::
NodeStoryEnv
err
->
[
NodeId
]
->
DBQuery
err
x
NodeListStory
getNodeListStoryMulti
=
view
nse_getter_multi
listNgramsFromRepo
::
[
ListId
]
listNgramsFromRepo
::
[
ListId
]
...
@@ -102,26 +88,27 @@ listNgramsFromRepo nodeIds ngramsType repo =
...
@@ -102,26 +88,27 @@ listNgramsFromRepo nodeIds ngramsType repo =
-- Add a static capability parameter would be nice.
-- Add a static capability parameter would be nice.
-- Ideally this is the access to `repoVar` which needs to
-- Ideally this is the access to `repoVar` which needs to
-- be properly guarded.
-- be properly guarded.
getListNgrams
::
HasNodeStory
env
err
m
getListNgrams
::
NodeStoryEnv
err
=>
[
ListId
]
->
NgramsType
->
[
ListId
]
->
m
(
DBQuery
err
x
(
HashMap
NgramsTerm
NgramsRepoElement
))
->
NgramsType
getListNgrams
nodeIds
ngramsType
=
fmap
(
listNgramsFromRepo
nodeIds
ngramsType
)
->
DBQuery
err
x
(
HashMap
NgramsTerm
NgramsRepoElement
)
<$>
getRepo
nodeIds
getListNgrams
env
nodeIds
ngramsType
=
listNgramsFromRepo
nodeIds
ngramsType
<$>
getRepo
env
nodeIds
-- | Fetch terms from repo, gathering terms under the same root (parent).
-- | Fetch terms from repo, gathering terms under the same root (parent).
getTermsWith
::
forall
a
e
nv
err
m
x
.
getTermsWith
::
forall
a
e
rr
x
.
Hashable
a
(
HasNodeStory
env
err
m
,
Eq
a
,
Hashable
a
)
=>
NodeStoryEnv
err
=
>
(
NgramsTerm
->
a
)
->
[
ListId
]
-
>
(
NgramsTerm
->
a
)
->
[
ListId
]
->
NgramsType
->
Set
ListType
->
NgramsType
->
Set
ListType
->
m
(
DBQuery
err
x
(
HashMap
a
[
a
])
)
->
DBQuery
err
x
(
HashMap
a
[
a
]
)
getTermsWith
f
ls
ngt
lts
=
getTermsWith
env
f
ls
ngt
lts
=
let
func
=
HM
.
fromListWith
(
<>
)
let
func
=
HM
.
fromListWith
(
<>
)
.
map
toTreeWith
.
map
toTreeWith
.
HM
.
toList
.
HM
.
toList
.
HM
.
filter
(
\
f'
->
Set
.
member
(
fst
f'
)
lts
)
.
HM
.
filter
(
\
f'
->
Set
.
member
(
fst
f'
)
lts
)
.
mapTermListRoot
ls
ngt
.
mapTermListRoot
ls
ngt
in
f
map
func
<$>
getRepo
ls
in
f
unc
<$>
getRepo
env
ls
where
where
toTreeWith
::
(
NgramsTerm
,
(
b
,
Maybe
NgramsTerm
))
->
(
a
,
[
a
])
toTreeWith
::
(
NgramsTerm
,
(
b
,
Maybe
NgramsTerm
))
->
(
a
,
[
a
])
toTreeWith
(
t
,
(
_lt
,
maybeRoot
))
=
case
maybeRoot
of
toTreeWith
(
t
,
(
_lt
,
maybeRoot
))
=
case
maybeRoot
of
...
...
src/Gargantext/API/Node/Corpus/Export/Utils.hs
View file @
d57a2246
...
@@ -15,6 +15,7 @@ module Gargantext.API.Node.Corpus.Export.Utils
...
@@ -15,6 +15,7 @@ module Gargantext.API.Node.Corpus.Export.Utils
where
where
import
Control.Exception.Safe
qualified
as
CES
import
Control.Exception.Safe
qualified
as
CES
import
Control.Lens
(
view
)
import
Control.Monad.Fail
(
fail
)
import
Control.Monad.Fail
(
fail
)
import
Data.Aeson
qualified
as
Aeson
import
Data.Aeson
qualified
as
Aeson
import
Data.ByteString.Lazy
qualified
as
BSL
import
Data.ByteString.Lazy
qualified
as
BSL
...
@@ -29,7 +30,7 @@ import Database.SQLite.Simple qualified as S
...
@@ -29,7 +30,7 @@ import Database.SQLite.Simple qualified as S
import
Gargantext.API.Ngrams.Tools
(
filterListWithRoot
,
mapTermListRoot
,
getRepo
)
import
Gargantext.API.Ngrams.Tools
(
filterListWithRoot
,
mapTermListRoot
,
getRepo
)
import
Gargantext.API.Ngrams.Types
(
NgramsTerm
(
..
)
)
import
Gargantext.API.Ngrams.Types
(
NgramsTerm
(
..
)
)
import
Gargantext.API.Node.Corpus.Export.Types
(
CorpusSQLite
(
..
),
CorpusSQLiteData
(
..
))
import
Gargantext.API.Node.Corpus.Export.Types
(
CorpusSQLite
(
..
),
CorpusSQLiteData
(
..
))
import
Gargantext.Core.NodeStory.Types
(
HasNodeStoryEnv
,
NodeListStory
)
import
Gargantext.Core.NodeStory.Types
(
HasNodeStoryEnv
(
hasNodeStory
)
,
NodeListStory
)
import
Gargantext.Core.Text.Ngrams
(
NgramsType
(
NgramsTerms
))
import
Gargantext.Core.Text.Ngrams
(
NgramsType
(
NgramsTerms
))
import
Gargantext.Core.Types
(
CorpusId
,
ListId
,
NodeType
(
NodeList
))
import
Gargantext.Core.Types
(
CorpusId
,
ListId
,
NodeType
(
NodeList
))
import
Gargantext.Core.Types.Main
(
ListType
(
..
))
import
Gargantext.Core.Types.Main
(
ListType
(
..
))
...
@@ -40,12 +41,12 @@ import Gargantext.Database.Admin.Types.Hyperdata.Document (HyperdataDocument)
...
@@ -40,12 +41,12 @@ import Gargantext.Database.Admin.Types.Hyperdata.Document (HyperdataDocument)
import
Gargantext.Database.Admin.Types.Hyperdata.List
(
HyperdataList
)
import
Gargantext.Database.Admin.Types.Hyperdata.List
(
HyperdataList
)
import
Gargantext.Database.Admin.Types.Node
(
unNodeId
,
ContextId
(
..
),
NodeId
(
UnsafeMkNodeId
))
import
Gargantext.Database.Admin.Types.Node
(
unNodeId
,
ContextId
(
..
),
NodeId
(
UnsafeMkNodeId
))
import
Gargantext.Database.Prelude
import
Gargantext.Database.Prelude
import
Gargantext.Database.Schema.Context
(
context_id
,
context_name
,
context_date
,
context_hyperdata
)
import
Gargantext.Database.Schema.Node
(
node_hash_id
,
node_hyperdata
,
node_name
,
node_parent_id
)
import
Gargantext.Database.Query.Table.Node
(
defaultList
,
getNodeWith
)
import
Gargantext.Database.Query.Table.Node
(
defaultList
,
getNodeWith
)
import
Gargantext.Database.Query.Table.NodeContext
(
selectDocNodes
)
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
)
import
Gargantext.Database.Query.Table.Node.Error
(
HasNodeError
)
import
Gargantext.Database.Query.Table.Node.Select
(
selectNodesWithUsername
)
import
Gargantext.Database.Query.Table.Node.Select
(
selectNodesWithUsername
)
import
Gargantext.Database.Query.Table.NodeContext
(
selectDocNodes
)
import
Gargantext.Database.Schema.Context
(
context_id
,
context_name
,
context_date
,
context_hyperdata
)
import
Gargantext.Database.Schema.Node
(
node_hash_id
,
node_hyperdata
,
node_name
,
node_parent_id
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.System.Logging
(
logLocM
,
LogLevel
(
..
),
MonadLogger
)
import
Gargantext.System.Logging
(
logLocM
,
LogLevel
(
..
),
MonadLogger
)
import
Paths_gargantext
qualified
as
PG
-- cabal magic build module
import
Paths_gargantext
qualified
as
PG
-- cabal magic build module
...
@@ -85,6 +86,7 @@ mkCorpusSQLiteData :: ( CES.MonadMask m
...
@@ -85,6 +86,7 @@ mkCorpusSQLiteData :: ( CES.MonadMask m
->
Maybe
ListId
->
Maybe
ListId
->
m
CorpusSQLiteData
->
m
CorpusSQLiteData
mkCorpusSQLiteData
cId
lId
=
do
mkCorpusSQLiteData
cId
lId
=
do
env
<-
view
hasNodeStory
corpus
<-
runDBQuery
$
getNodeWith
cId
(
Proxy
@
HyperdataCorpus
)
corpus
<-
runDBQuery
$
getNodeWith
cId
(
Proxy
@
HyperdataCorpus
)
now
<-
liftBase
getCurrentTime
now
<-
liftBase
getCurrentTime
...
@@ -92,7 +94,7 @@ mkCorpusSQLiteData cId lId = do
...
@@ -92,7 +94,7 @@ mkCorpusSQLiteData cId lId = do
Nothing
->
runDBQuery
$
defaultList
cId
Nothing
->
runDBQuery
$
defaultList
cId
Just
l
->
pure
l
Just
l
->
pure
l
repo
<-
runDBQuery
=<<
getRepo
[
listId
]
repo
<-
runDBQuery
$
getRepo
env
[
listId
]
runDBQuery
$
do
runDBQuery
$
do
l
<-
getNodeWith
listId
(
Proxy
@
HyperdataList
)
l
<-
getNodeWith
listId
(
Proxy
@
HyperdataList
)
...
...
src/Gargantext/Core/NodeStory.hs
View file @
d57a2246
...
@@ -315,8 +315,8 @@ fromDBNodeStoryEnv pool = do
...
@@ -315,8 +315,8 @@ fromDBNodeStoryEnv pool = do
-- ) $ Map.toList nls
-- ) $ Map.toList nls
-- pure $ clearHistory ns
-- pure $ clearHistory ns
pure
$
NodeStoryEnv
{
_nse_saver
_immediate
=
saver_immediate
pure
$
NodeStoryEnv
{
_nse_saver
=
saver_immediate
,
_nse_archive_saver
_immediate
=
archive_saver_immediate
,
_nse_archive_saver
=
archive_saver_immediate
,
_nse_getter
=
\
nId
->
withResource
pool
$
\
c
->
,
_nse_getter
=
\
nId
->
withResource
pool
$
\
c
->
getNodeStory'
c
nId
getNodeStory'
c
nId
,
_nse_getter_multi
=
\
nIds
->
withResource
pool
$
\
c
->
,
_nse_getter_multi
=
\
nIds
->
withResource
pool
$
\
c
->
...
...
src/Gargantext/Core/NodeStory/Types.hs
View file @
d57a2246
...
@@ -30,8 +30,8 @@ module Gargantext.Core.NodeStory.Types
...
@@ -30,8 +30,8 @@ module Gargantext.Core.NodeStory.Types
,
initNodeStory
,
initNodeStory
,
nse_getter
,
nse_getter
,
nse_getter_multi
,
nse_getter_multi
,
nse_saver
_immediate
,
nse_saver
,
nse_archive_saver
_immediate
,
nse_archive_saver
-- , nse_var
-- , nse_var
,
unNodeStory
,
unNodeStory
,
Archive
(
..
)
,
Archive
(
..
)
...
@@ -188,22 +188,17 @@ type ArchiveList = Archive NgramsState' NgramsStatePatch'
...
@@ -188,22 +188,17 @@ type ArchiveList = Archive NgramsState' NgramsStatePatch'
------------------------------------------------------------------------
------------------------------------------------------------------------
data
NodeStoryEnv
err
=
NodeStoryEnv
data
NodeStoryEnv
err
=
NodeStoryEnv
{
_nse_saver
_immediate
::
!
(
NodeId
->
ArchiveList
->
DBUpdate
err
()
)
{
_nse_saver
::
!
(
NodeId
->
ArchiveList
->
DBUpdate
err
()
)
,
_nse_archive_saver
_immediate
::
!
(
NodeId
->
ArchiveList
->
DBUpdate
err
ArchiveList
)
,
_nse_archive_saver
::
!
(
NodeId
->
ArchiveList
->
DBUpdate
err
ArchiveList
)
,
_nse_getter
::
!
(
forall
x
.
NodeId
->
DBQuery
err
x
ArchiveList
)
,
_nse_getter
::
!
(
forall
x
.
NodeId
->
DBQuery
err
x
ArchiveList
)
,
_nse_getter_multi
::
!
(
forall
x
.
[
NodeId
]
->
DBQuery
err
x
NodeListStory
)
,
_nse_getter_multi
::
!
(
forall
x
.
[
NodeId
]
->
DBQuery
err
x
NodeListStory
)
--, _nse_cleaner :: !(IO ()) -- every 12 hours: cleans the repos of unused NodeStories
--, _nse_cleaner :: !(IO ()) -- every 12 hours: cleans the repos of unused NodeStories
-- , _nse_lock :: !FileLock -- TODO (it depends on the option: if with database or file only)
-- , _nse_lock :: !FileLock -- TODO (it depends on the option: if with database or file only)
}
}
type
HasNodeStory
env
err
m
=
(
IsDBCmd
env
err
m
type
HasNodeStory
env
err
m
=
(
Monad
m
,
HasNodeStoryEnv
env
err
,
HasNodeError
err
)
,
MonadReader
env
m
,
MonadError
err
m
,
HasNodeStoryEnv
env
err
,
HasNodeError
err
)
class
(
HasNodeStoryImmediateSaver
err
env
)
class
HasNodeStoryImmediateSaver
err
env
=>
HasNodeStoryEnv
env
err
where
=>
HasNodeStoryEnv
env
err
where
hasNodeStory
::
Getter
env
(
NodeStoryEnv
err
)
hasNodeStory
::
Getter
env
(
NodeStoryEnv
err
)
...
...
src/Gargantext/Database/Query/Table/Node/Update.hs
View file @
d57a2246
...
@@ -24,7 +24,7 @@ import Gargantext.Core.Notifications.CentralExchange.Types qualified as CE
...
@@ -24,7 +24,7 @@ import Gargantext.Core.Notifications.CentralExchange.Types qualified as CE
import
Gargantext.Core.Types
(
Name
)
import
Gargantext.Core.Types
(
Name
)
import
Gargantext.Database.Admin.Config
()
import
Gargantext.Database.Admin.Config
()
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Prelude
(
DBCmd
,
DBCmdExtra
,
runPGSQuery
)
import
Gargantext.Database.Prelude
import
Gargantext.Database.Query.Table.Node.Error
import
Gargantext.Database.Query.Table.Node.Error
import
Gargantext.Database.Query.Table.Node
(
getParentId
,
getNode
,
getUserRootPublicNode
)
import
Gargantext.Database.Query.Table.Node
(
getParentId
,
getNode
,
getUserRootPublicNode
)
import
Gargantext.Database.Query.Table.NodeNode
(
isNodeReadOnly
,
SourceId
(
..
),
TargetId
(
..
),
publishNode
,
unpublishNode
)
import
Gargantext.Database.Query.Table.NodeNode
(
isNodeReadOnly
,
SourceId
(
..
),
TargetId
(
..
),
publishNode
,
unpublishNode
)
...
@@ -48,20 +48,20 @@ unOnly :: Only a -> a
...
@@ -48,20 +48,20 @@ unOnly :: Only a -> a
unOnly
(
Only
a
)
=
a
unOnly
(
Only
a
)
=
a
-- | Prefer this, because it notifies parents of the node change
-- | Prefer this, because it notifies parents of the node change
update
::
HasNodeError
err
=>
UserId
->
Update
->
DB
CmdExtra
err
[
Int
]
update
::
HasNodeError
err
=>
UserId
->
Update
->
DB
Update
err
([
Int
],
[
CE
.
CEMessage
])
update
_loggedInUserId
(
Rename
nId
newName
)
=
do
update
_loggedInUserId
(
Rename
nId
newName
)
=
do
ret
<-
rename_db_update
nId
newName
ret
<-
rename_db_update
nId
newName
mpId
<-
getParentId
nId
mpId
<-
getParentId
nId
case
mpId
of
let
msgs
=
case
mpId
of
Nothing
->
pure
()
Nothing
->
mempty
Just
pId
->
CE
.
ce_notify
$
CE
.
UpdateTreeFirstLevel
pId
Just
pId
->
[
CE
.
UpdateTreeFirstLevel
pId
]
return
ret
pure
$
(
ret
,
msgs
)
update
loggedInUserId
(
Move
sourceId
targetId
)
=
do
update
loggedInUserId
(
Move
sourceId
targetId
)
=
do
mbParentId
<-
getParentId
sourceId
mbParentId
<-
getParentId
sourceId
-- if the source and the target are the same, this is identity.
-- if the source and the target are the same, this is identity.
if
sourceId
==
targetId
if
sourceId
==
targetId
then
pure
[
_NodeId
sourceId
]
then
pure
([
_NodeId
sourceId
],
mempty
)
else
do
else
do
isSourceRO
<-
isNodeReadOnly
sourceId
isSourceRO
<-
isNodeReadOnly
sourceId
isTargetRO
<-
isNodeReadOnly
targetId
isTargetRO
<-
isNodeReadOnly
targetId
...
@@ -94,17 +94,16 @@ update loggedInUserId (Move sourceId targetId) = do
...
@@ -94,17 +94,16 @@ update loggedInUserId (Move sourceId targetId) = do
-- this case is not allowed.
-- this case is not allowed.
nodeError
(
NodeIsReadOnly
targetId
"Both the source and the target are read-only."
)
nodeError
(
NodeIsReadOnly
targetId
"Both the source and the target are read-only."
)
for_
mbParentId
$
CE
.
ce_notify
.
CE
.
UpdateTreeFirstLevel
let
msgs
=
catMaybes
[
CE
.
UpdateTreeFirstLevel
<$>
mbParentId
,
Just
(
CE
.
UpdateTreeFirstLevel
targetId
)]
CE
.
ce_notify
$
CE
.
UpdateTreeFirstLevel
targetId
pure
ids
pure
(
ids
,
msgs
)
publish
::
HasNodeError
err
=>
UserId
->
NodeId
->
NodePublishPolicy
->
DB
CmdExtra
err
Int
publish
::
HasNodeError
err
=>
UserId
->
NodeId
->
NodePublishPolicy
->
DB
Update
err
Int
publish
loggedInUserId
sourceId
policy
=
do
publish
loggedInUserId
sourceId
policy
=
do
targetId
<-
_node_id
<$>
getUserRootPublicNode
loggedInUserId
targetId
<-
_node_id
<$>
getUserRootPublicNode
loggedInUserId
publish_node
(
SourceId
sourceId
)
(
TargetId
targetId
)
policy
publish_node
(
SourceId
sourceId
)
(
TargetId
targetId
)
policy
publish_node
::
HasNodeError
err
=>
SourceId
->
TargetId
->
NodePublishPolicy
->
DB
CmdExtra
err
Int
publish_node
::
HasNodeError
err
=>
SourceId
->
TargetId
->
NodePublishPolicy
->
DB
Update
err
Int
publish_node
(
SourceId
sourceId
)
(
TargetId
targetId
)
policy
=
do
publish_node
(
SourceId
sourceId
)
(
TargetId
targetId
)
policy
=
do
sourceNode
<-
getNode
sourceId
sourceNode
<-
getNode
sourceId
targetNode
<-
getNode
targetId
targetNode
<-
getNode
targetId
...
@@ -126,15 +125,15 @@ publish_node (SourceId sourceId) (TargetId targetId) policy = do
...
@@ -126,15 +125,15 @@ publish_node (SourceId sourceId) (TargetId targetId) policy = do
-- Issue #400, for now we support only publishing corpus nodes
-- Issue #400, for now we support only publishing corpus nodes
check_publish_source_type_allowed
::
HasNodeError
err
=>
SourceId
->
TargetId
->
NodeType
->
DB
CmdExtra
er
r
()
check_publish_source_type_allowed
::
HasNodeError
err
=>
SourceId
->
TargetId
->
NodeType
->
DB
Tx
err
r
()
check_publish_source_type_allowed
(
SourceId
nId
)
(
TargetId
tId
)
=
\
case
check_publish_source_type_allowed
(
SourceId
nId
)
(
TargetId
tId
)
=
\
case
NodeCorpus
->
pure
()
NodeCorpus
->
pure
()
NodeCorpusV3
->
pure
()
NodeCorpusV3
->
pure
()
_
->
nodeError
(
MoveError
nId
tId
"At the moment only corpus nodes can be published."
)
_
->
nodeError
(
MoveError
nId
tId
"At the moment only corpus nodes can be published."
)
-- TODO-ACCESS
-- TODO-ACCESS
rename_db_update
::
NodeId
->
Name
->
DB
Cmd
err
[
Int
]
rename_db_update
::
NodeId
->
Name
->
DB
Update
err
[
Int
]
rename_db_update
nId
name
=
map
unOnly
<$>
runPGSQuer
y
"UPDATE nodes SET name=? where id=? returning id"
(
DT
.
take
255
name
,
nId
)
rename_db_update
nId
name
=
map
unOnly
<$>
mkPGUpdateReturningMan
y
"UPDATE nodes SET name=? where id=? returning id"
(
DT
.
take
255
name
,
nId
)
move_db_update
::
NodeId
->
NodeId
->
DB
Cmd
err
[
Int
]
move_db_update
::
NodeId
->
NodeId
->
DB
Update
err
[
Int
]
move_db_update
nId
pId
=
map
unOnly
<$>
runPGSQuer
y
"UPDATE nodes SET parent_id= ? where id=? returning id"
(
pId
,
nId
)
move_db_update
nId
pId
=
map
unOnly
<$>
mkPGUpdateReturningMan
y
"UPDATE nodes SET parent_id= ? where id=? returning id"
(
pId
,
nId
)
src/Gargantext/Database/Transactional/Example.hs
View file @
d57a2246
...
@@ -18,7 +18,6 @@ import Gargantext.Database.Query.Table.NodeNode qualified as GGTX hiding (insert
...
@@ -18,7 +18,6 @@ import Gargantext.Database.Query.Table.NodeNode qualified as GGTX hiding (insert
import
Gargantext.Database.Query.Tree.Root
(
selectRoot
)
import
Gargantext.Database.Query.Tree.Root
(
selectRoot
)
import
Gargantext.Database.Schema.Node
(
_node_id
)
import
Gargantext.Database.Schema.Node
(
_node_id
)
import
Gargantext.Database.Schema.Node
(
node_user_id
)
import
Gargantext.Database.Schema.Node
(
node_user_id
)
import
Gargantext.Database.Transactional
import
Gargantext.Prelude
(
panicTrace
,
headMay
)
import
Gargantext.Prelude
(
panicTrace
,
headMay
)
import
Opaleye
import
Opaleye
import
Prelude
import
Prelude
...
...
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