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
ea5025d3
Commit
ea5025d3
authored
Jul 27, 2021
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NodeStory] getter fun (WIP)
parent
10b2cb3e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
21 deletions
+46
-21
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+37
-14
NodeStory.hs
src/Gargantext/Core/NodeStory.hs
+9
-7
No files found.
src/Gargantext/API/Ngrams.hs
View file @
ea5025d3
...
...
@@ -102,9 +102,12 @@ import Formatting (hprint, int, (%))
import
GHC.Generics
(
Generic
)
import
Gargantext.API.Admin.Orchestrator.Types
(
JobLog
(
..
),
AsyncJobs
)
import
Gargantext.API.Admin.Types
(
HasSettings
)
import
Gargantext.API.Job
import
Gargantext.API.Ngrams.Types
import
Gargantext.API.Prelude
import
Gargantext.Core.NodeStory
import
Gargantext.Core.Types
(
ListType
(
..
),
NodeId
,
ListId
,
DocId
,
Limit
,
Offset
,
TODO
,
assertValid
)
import
Gargantext.API.Ngrams.Tools
import
Gargantext.Core.Utils
(
something
)
import
Gargantext.Database.Action.Flow.Types
import
Gargantext.Database.Action.Metrics.NgramsByNode
(
getOccByNgramsOnlyFast'
)
...
...
@@ -117,7 +120,6 @@ import Gargantext.Database.Query.Table.Node.Error (HasNodeError)
import
Gargantext.Database.Query.Table.Node.Select
import
Gargantext.Database.Schema.Node
(
node_id
,
node_parent_id
,
node_user_id
)
import
Gargantext.Prelude
hiding
(
log
)
import
Gargantext.API.Job
import
Gargantext.Prelude.Clock
(
hasTime
,
getTime
)
import
Prelude
(
error
)
import
Servant
hiding
(
Patch
)
...
...
@@ -184,6 +186,11 @@ mkChildrenGroups addOrRem nt patches =
saveRepo
::
(
MonadReader
env
m
,
MonadBase
IO
m
,
HasRepoSaver
env
)
=>
m
()
saveRepo
=
liftBase
=<<
view
repoSaver
saveRepo'
::
(
MonadReader
env
m
,
MonadBase
IO
m
,
HasNodeStorySaver
env
)
=>
m
()
saveRepo'
=
liftBase
=<<
view
hasNodeStorySaver
listTypeConflictResolution
::
ListType
->
ListType
->
ListType
listTypeConflictResolution
_
_
=
undefined
-- TODO Use Map User ListType
...
...
@@ -237,16 +244,10 @@ addListNgrams listId ngramsType nes = do
m = Map.fromList $ (\n -> (n ^. ne_ngrams, n)) <$> nes
-}
-- UNSAFE
rmListNgrams
::
RepoCmdM
env
err
m
=>
ListId
->
TableNgrams
.
NgramsType
->
m
()
rmListNgrams
l
nt
=
setListNgrams
l
nt
mempty
-- | TODO: incr the Version number
-- && should use patch
-- UNSAFE
setListNgrams
::
RepoCmdM
env
err
m
=>
NodeId
->
TableNgrams
.
NgramsType
...
...
@@ -256,14 +257,27 @@ setListNgrams listId ngramsType ns = do
var
<-
view
repoVar
liftBase
$
modifyMVar_
var
$
pure
.
(
r_state
.
at
ngramsType
%~
(
Just
.
(
at
listId
.~
(
Just
ns
))
.
something
)
.
at
ngramsType
%~
Just
.
(
at
listId
.~
Just
ns
)
.
something
)
printDebug
"List modified"
NodeList
saveRepo
setListNgrams'
::
HasNodeStory
env
err
m
=>
NodeId
->
TableNgrams
.
NgramsType
->
Map
NgramsTerm
NgramsRepoElement
->
m
()
setListNgrams'
listId
ngramsType
ns
=
do
getter
<-
view
hasNodeStory
var
<-
liftBase
$
(
getter
^.
nse_getter
)
listId
liftBase
$
modifyMVar_
var
$
pure
.
(
unNodeStory
.
at
listId
.
_Just
.
a_state
.
at
ngramsType
.~
Just
ns
)
saveRepo'
currentVersion
::
RepoCmdM
env
err
m
...
...
@@ -272,6 +286,14 @@ currentVersion = do
var
<-
view
repoVar
r
<-
liftBase
$
readMVar
var
pure
$
r
^.
r_version
currentVersion'
::
HasNodeStory
env
err
m
=>
ListId
->
m
Version
currentVersion'
listId
=
do
nls
<-
getRepo'
[
listId
]
pure
$
nls
^.
unNodeStory
.
at
listId
.
_Just
.
a_version
newNgramsFromNgramsStatePatch
::
NgramsStatePatch
->
[
Ngrams
]
newNgramsFromNgramsStatePatch
p
=
...
...
@@ -282,7 +304,8 @@ newNgramsFromNgramsStatePatch p =
-- tableNgramsPut :: (HasInvalidError err, RepoCmdM env err m)
commitStatePatch
::
RepoCmdM
env
err
m
=>
Versioned
NgramsStatePatch
->
m
(
Versioned
NgramsStatePatch
)
=>
Versioned
NgramsStatePatch
->
m
(
Versioned
NgramsStatePatch
)
commitStatePatch
(
Versioned
p_version
p
)
=
do
var
<-
view
repoVar
vq'
<-
liftBase
$
modifyMVar
var
$
\
r
->
do
...
...
src/Gargantext/Core/NodeStory.hs
View file @
ea5025d3
...
...
@@ -18,6 +18,8 @@ module Gargantext.Core.NodeStory where
import
System.IO
(
FilePath
,
hClose
)
import
Data.Maybe
(
fromMaybe
)
import
Codec.Serialise
(
Serialise
(),
serialise
,
deserialise
)
import
Control.Monad.Reader
import
Control.Monad.Except
import
Control.Concurrent
(
MVar
(),
withMVar
,
newMVar
)
import
Control.Lens
(
makeLenses
,
Getter
,
(
^.
))
import
Data.Aeson
hiding
((
.=
))
...
...
@@ -47,11 +49,13 @@ data NodeStoryEnv = NodeStoryEnv
}
deriving
(
Generic
)
type
HasNodeStory
env
err
m
=
(
CmdM'
env
err
m
,
HasNodeStoryEnv
env
,
HasConfig
env
,
HasConnectionPool
env
)
type
HasNodeStory
env
err
m
=
(
CmdM'
env
err
m
,
MonadReader
env
m
,
MonadError
err
m
,
HasNodeStoryEnv
env
,
HasConfig
env
,
HasConnectionPool
env
)
class
(
HasNodeStoryVar
env
,
HasNodeStorySaver
env
)
=>
HasNodeStoryEnv
env
where
...
...
@@ -63,8 +67,6 @@ class HasNodeStoryVar env where
class
HasNodeStorySaver
env
where
hasNodeStorySaver
::
Getter
env
(
IO
()
)
------------------------------------------------------------------------
readNodeStoryEnv
::
NodeStoryDir
->
IO
NodeStoryEnv
readNodeStoryEnv
nsd
=
do
...
...
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