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
4e134509
Commit
4e134509
authored
Aug 31, 2021
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NAMING] Repo -> NodeStory
parent
f05e7b07
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
51 deletions
+48
-51
API.hs
src/Gargantext/API.hs
+2
-2
Dev.hs
src/Gargantext/API/Dev.hs
+2
-2
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+10
-10
Tools.hs
src/Gargantext/API/Ngrams/Tools.hs
+2
-2
List.hs
src/Gargantext/Core/Text/List.hs
+1
-1
List.hs
src/Gargantext/Database/Action/Flow/List.hs
+31
-34
No files found.
src/Gargantext/API.hs
View file @
4e134509
...
...
@@ -43,7 +43,7 @@ import GHC.Generics (Generic)
import
Gargantext.API.Admin.Auth.Types
(
AuthContext
)
import
Gargantext.API.Admin.Settings
(
newEnv
)
import
Gargantext.API.Admin.Types
(
FireWall
(
..
),
PortNumber
,
cookieSettings
,
jwtSettings
,
settings
)
import
Gargantext.API.Ngrams
(
save
Repo
)
import
Gargantext.API.Ngrams
(
save
NodeStory
)
import
Gargantext.API.Prelude
import
Gargantext.API.Routes
import
Gargantext.API.Server
(
server
)
...
...
@@ -80,7 +80,7 @@ portRouteInfo port = do
stopGargantext
::
HasNodeStorySaver
env
=>
env
->
IO
()
stopGargantext
env
=
do
putStrLn
"----- Stopping gargantext -----"
runReaderT
save
Repo
env
runReaderT
save
NodeStory
env
{-
startGargantextMock :: PortNumber -> IO ()
...
...
src/Gargantext/API/Dev.hs
View file @
4e134509
...
...
@@ -17,7 +17,7 @@ import Control.Monad (fail)
import
Control.Monad.Reader
(
runReaderT
)
import
Gargantext.API.Admin.EnvTypes
import
Gargantext.API.Admin.Settings
import
Gargantext.API.Ngrams
(
save
Repo
)
import
Gargantext.API.Ngrams
(
save
NodeStory
)
import
Gargantext.API.Prelude
import
Gargantext.Core.NodeStory
import
Gargantext.Database.Prelude
...
...
@@ -64,7 +64,7 @@ runCmdDev :: (Show err) => DevEnv -> Cmd'' DevEnv err a -> IO a
runCmdDev
env
f
=
(
either
(
fail
.
show
)
pure
=<<
runCmd
env
f
)
`
finally
`
runReaderT
save
Repo
env
runReaderT
save
NodeStory
env
runCmdDevNoErr
::
DevEnv
->
Cmd'
DevEnv
()
a
->
IO
a
runCmdDevNoErr
=
runCmdDev
...
...
src/Gargantext/API/Ngrams.hs
View file @
4e134509
...
...
@@ -54,7 +54,7 @@ module Gargantext.API.Ngrams
,
r_history
,
NgramsRepo
,
NgramsRepoElement
(
..
)
,
save
Repo
,
save
NodeStory
,
initRepo
,
RepoEnv
(
..
)
...
...
@@ -178,9 +178,9 @@ mkChildrenGroups addOrRem nt patches =
------------------------------------------------------------------------
save
Repo
::
(
MonadReader
env
m
,
MonadBase
IO
m
,
HasNodeStorySaver
env
)
save
NodeStory
::
(
MonadReader
env
m
,
MonadBase
IO
m
,
HasNodeStorySaver
env
)
=>
m
()
save
Repo
=
liftBase
=<<
view
hasNodeStorySaver
save
NodeStory
=
liftBase
=<<
view
hasNodeStorySaver
listTypeConflictResolution
::
ListType
->
ListType
->
ListType
...
...
@@ -217,7 +217,7 @@ copyListNgrams srcListId dstListId ngramsType = do
var <- view repoVar
liftBase $ modifyMVar_ var $
pure . (r_state . at ngramsType %~ (Just . f . something))
save
Repo
save
NodeStory
where
f :: Map NodeId NgramsTableMap -> Map NodeId NgramsTableMap
f m = m & at dstListId %~ insertNewOnly (m ^. at srcListId)
...
...
@@ -232,7 +232,7 @@ addListNgrams listId ngramsType nes = do
var <- view repoVar
liftBase $ modifyMVar_ var $
pure . (r_state . at ngramsType . _Just . at listId . _Just <>~ m)
save
Repo
save
NodeStory
where
m = Map.fromList $ (\n -> (n ^. ne_ngrams, n)) <$> nes
-}
...
...
@@ -257,7 +257,7 @@ setListNgrams listId ngramsType ns = do
.
at
ngramsType
.~
Just
ns
)
save
Repo
save
NodeStory
currentVersion
::
HasNodeStory
env
err
m
...
...
@@ -286,7 +286,7 @@ commitStatePatch :: HasNodeStory env err m
->
m
(
Versioned
NgramsStatePatch'
)
commitStatePatch
listId
(
Versioned
p_version
p
)
=
do
printDebug
"[commitStatePatch]"
listId
var
<-
get
Repo
Var
[
listId
]
var
<-
get
NodeStory
Var
[
listId
]
vq'
<-
liftBase
$
modifyMVar
var
$
\
ns
->
do
let
a
=
ns
^.
unNodeStory
.
at
listId
.
_Just
...
...
@@ -312,7 +312,7 @@ commitStatePatch listId (Versioned p_version p) = do
pure
(
ns
&
unNodeStory
.
at
listId
.~
(
Just
a'
)
,
Versioned
(
a'
^.
a_version
)
q'
)
save
Repo
save
NodeStory
-- Save new ngrams
_
<-
insertNgrams
(
newNgramsFromNgramsStatePatch
p
)
...
...
@@ -328,7 +328,7 @@ tableNgramsPull :: HasNodeStory env err m
->
m
(
Versioned
NgramsTablePatch
)
tableNgramsPull
listId
ngramsType
p_version
=
do
printDebug
"[tableNgramsPull]"
(
listId
,
ngramsType
)
var
<-
get
Repo
Var
[
listId
]
var
<-
get
NodeStory
Var
[
listId
]
r
<-
liftBase
$
readMVar
var
let
...
...
@@ -467,7 +467,7 @@ getNgramsTableMap :: HasNodeStory env err m
->
TableNgrams
.
NgramsType
->
m
(
Versioned
NgramsTableMap
)
getNgramsTableMap
nodeId
ngramsType
=
do
v
<-
get
Repo
Var
[
nodeId
]
v
<-
get
NodeStory
Var
[
nodeId
]
repo
<-
liftBase
$
readMVar
v
pure
$
Versioned
(
repo
^.
unNodeStory
.
at
nodeId
.
_Just
.
a_version
)
(
repo
^.
unNodeStory
.
at
nodeId
.
_Just
.
a_state
.
at
ngramsType
.
_Just
)
...
...
src/Gargantext/API/Ngrams/Tools.hs
View file @
4e134509
...
...
@@ -51,9 +51,9 @@ getRepo' listIds = do
pure
$
v'
get
Repo
Var
::
HasNodeStory
env
err
m
get
NodeStory
Var
::
HasNodeStory
env
err
m
=>
[
ListId
]
->
m
(
MVar
NodeListStory
)
get
Repo
Var
l
=
do
get
NodeStory
Var
l
=
do
f
<-
getNodeListStory
v
<-
liftBase
$
f
l
pure
v
...
...
src/Gargantext/Core/Text/List.hs
View file @
4e134509
...
...
@@ -220,7 +220,7 @@ buildNgramsTermsList user uCid mCid groupParams (nt, _mapListSize)= do
$
setScoresWithMap
mapTextDocIds
(
groupedMonoHead
<>
groupedMultHead
)
printDebug
"groupedTreeScores_SetNodeId"
groupedTreeScores_SetNodeId
--
printDebug "groupedTreeScores_SetNodeId" groupedTreeScores_SetNodeId
-- Coocurrences computation
--, t1 >= t2 -- permute byAxis diag -- since matrix symmetric
...
...
src/Gargantext/Database/Action/Flow/List.hs
View file @
4e134509
...
...
@@ -23,8 +23,8 @@ import Control.Monad.Reader
import
Data.Map
(
Map
,
toList
)
import
Data.Maybe
(
catMaybes
)
import
Data.Text
(
Text
)
import
Gargantext.API.Ngrams
(
save
Repo
)
import
Gargantext.API.Ngrams.Tools
(
get
Repo
Var
)
import
Gargantext.API.Ngrams
(
save
NodeStory
)
import
Gargantext.API.Ngrams.Tools
(
get
NodeStory
Var
)
import
Gargantext.API.Ngrams.Types
import
Gargantext.Core.Types
(
HasInvalidError
(
..
),
assertValid
)
import
Gargantext.Core.Types.Main
(
ListType
(
CandidateTerm
))
...
...
@@ -138,8 +138,6 @@ listInsert lId ngs = mapM_ (\(typeList, ngElmts)
------------------------------------------------------------------------
------------------------------------------------------------------------
-- NOTE
-- This is no longer part of the API.
-- This function is maintained for its usage in Database.Action.Flow.List.
...
...
@@ -155,34 +153,33 @@ putListNgrams nodeId ngramsType nes = putListNgrams' nodeId ngramsType m
where
m
=
Map
.
fromList
$
map
(
\
n
->
(
n
^.
ne_ngrams
,
ngramsElementToRepo
n
))
nes
putListNgrams'
::
(
HasInvalidError
err
,
HasNodeStory
env
err
m
)
=>
NodeId
->
TableNgrams
.
NgramsType
->
Map
NgramsTerm
NgramsRepoElement
->
m
()
putListNgrams'
listId
ngramsType
ns
=
do
-- printDebug "[putListNgrams'] nodeId" nodeId
-- printDebug "[putListNgrams'] ngramsType" ngramsType
-- printDebug "[putListNgrams'] ns" ns
let
p1
=
NgramsTablePatch
.
PM
.
fromMap
$
NgramsReplace
Nothing
.
Just
<$>
ns
(
p
,
p_validity
)
=
PM
.
singleton
ngramsType
p1
assertValid
p_validity
{-
-- TODO
v <- currentVersion
q <- commitStatePatch (Versioned v p)
assert empty q
-- What if another commit comes in between?
-- Shall we have a blindCommitStatePatch? It would not ask for a version but just a patch.
-- The modifyMVar_ would test the patch with applicable first.
-- If valid the rest would be atomic and no merge is required.
-}
var
<-
getRepoVar
[
listId
]
liftBase
$
modifyMVar_
var
$
\
r
->
do
pure
$
r
&
unNodeStory
.
at
listId
.
_Just
.
a_version
+~
1
&
unNodeStory
.
at
listId
.
_Just
.
a_history
%~
(
p
:
)
&
unNodeStory
.
at
listId
.
_Just
.
a_state
.
at
ngramsType
.~
Just
ns
saveRepo
putListNgrams'
::
(
HasInvalidError
err
,
HasNodeStory
env
err
m
)
=>
NodeId
->
TableNgrams
.
NgramsType
->
Map
NgramsTerm
NgramsRepoElement
->
m
()
putListNgrams'
listId
ngramsType'
ns
=
do
-- printDebug "[putListNgrams'] nodeId" nodeId
-- printDebug "[putListNgrams'] ngramsType" ngramsType
-- printDebug "[putListNgrams'] ns" ns
let
p1
=
NgramsTablePatch
.
PM
.
fromMap
$
NgramsReplace
Nothing
.
Just
<$>
ns
(
p
,
p_validity
)
=
PM
.
singleton
ngramsType'
p1
assertValid
p_validity
{-
-- TODO
v <- currentVersion
q <- commitStatePatch (Versioned v p)
assert empty q
-- What if another commit comes in between?
-- Shall we have a blindCommitStatePatch? It would not ask for a version but just a patch.
-- The modifyMVar_ would test the patch with applicable first.
-- If valid the rest would be atomic and no merge is required.
-}
var
<-
getNodeStoryVar
[
listId
]
liftBase
$
modifyMVar_
var
$
\
r
->
do
pure
$
r
&
unNodeStory
.
at
listId
.
_Just
.
a_version
+~
1
&
unNodeStory
.
at
listId
.
_Just
.
a_history
%~
(
p
:
)
&
unNodeStory
.
at
listId
.
_Just
.
a_state
.
at
ngramsType'
.~
Just
ns
saveNodeStory
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