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
195
Issues
195
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
dfb77185
Commit
dfb77185
authored
Jul 28, 2021
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] temp resolution of commitpatch
parent
ea5025d3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
5 deletions
+62
-5
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+47
-0
Tools.hs
src/Gargantext/API/Ngrams/Tools.hs
+6
-0
Types.hs
src/Gargantext/API/Ngrams/Types.hs
+1
-4
NodeStory.hs
src/Gargantext/Core/NodeStory.hs
+8
-1
No files found.
src/Gargantext/API/Ngrams.hs
View file @
dfb77185
...
...
@@ -204,9 +204,21 @@ ngramsStatePatchConflictResolution _ngramsType _nodeId _ngramsTerm
=
(
ours
,
(
const
ours
,
ours
),
(
False
,
False
))
-- (False, False) mean here that Mod has always priority.
-- (True, False) <- would mean priority to the left (same as ours).
-- undefined {- TODO think this through -}, listTypeConflictResolution)
ngramsStatePatchConflictResolution'
::
TableNgrams
.
NgramsType
->
NgramsTerm
->
ConflictResolutionNgramsPatch
ngramsStatePatchConflictResolution'
_ngramsType
_ngramsTerm
=
(
ours
,
(
const
ours
,
ours
),
(
False
,
False
))
-- (False, False) mean here that Mod has always priority.
-- (True, False) <- would mean priority to the left (same as ours).
-- undefined {- TODO think this through -}, listTypeConflictResolution)
-- Current state:
-- Insertions are not considered as patches,
-- they do not extend history,
...
...
@@ -301,6 +313,16 @@ newNgramsFromNgramsStatePatch p =
|
(
n
,
np
)
<-
p
^..
_PatchMap
.
each
.
_PatchMap
.
each
.
_NgramsTablePatch
.
_PatchMap
.
ifolded
.
withIndex
,
_
<-
np
^..
patch_new
.
_Just
]
newNgramsFromNgramsStatePatch'
::
NgramsStatePatch'
->
[
Ngrams
]
newNgramsFromNgramsStatePatch'
p
=
[
text2ngrams
(
unNgramsTerm
n
)
|
(
n
,
np
)
<-
p
^..
_PatchMap
-- . each . _PatchMap
.
each
.
_NgramsTablePatch
.
_PatchMap
.
ifolded
.
withIndex
,
_
<-
np
^..
patch_new
.
_Just
]
-- tableNgramsPut :: (HasInvalidError err, RepoCmdM env err m)
commitStatePatch
::
RepoCmdM
env
err
m
...
...
@@ -335,6 +357,31 @@ commitStatePatch (Versioned p_version p) = do
pure
vq'
commitStatePatch'
::
HasNodeStory
env
err
m
=>
ListId
->
Versioned
NgramsStatePatch'
->
m
(
Versioned
NgramsStatePatch'
)
commitStatePatch'
listId
(
Versioned
p_version
p
)
=
do
var
<-
getRepoVar
listId
vq'
<-
liftBase
$
modifyMVar
var
$
\
ns
->
do
let
a
=
ns
^.
unNodeStory
.
at
listId
.
_Just
q
=
mconcat
$
take
(
a
^.
a_version
-
p_version
)
(
a
^.
a_history
)
(
p'
,
q'
)
=
transformWith
ngramsStatePatchConflictResolution'
p
q
a'
=
a
&
a_version
+~
1
&
a_state
%~
act
p'
&
a_history
%~
(
p'
:
)
pure
(
ns
&
unNodeStory
.
at
listId
.~
(
Just
a'
)
,
Versioned
(
a'
^.
a_version
)
q'
)
saveRepo'
-- Save new ngrams
_
<-
insertNgrams
(
newNgramsFromNgramsStatePatch'
p
)
pure
$
vq'
-- This is a special case of tableNgramsPut where the input patch is empty.
tableNgramsPull
::
RepoCmdM
env
err
m
=>
ListId
...
...
src/Gargantext/API/Ngrams/Tools.hs
View file @
dfb77185
...
...
@@ -49,6 +49,12 @@ getRepo' listIds = do
Nothing
->
panic
"[G.A.N.Tools.getRepo']"
Just
nls
->
pure
nls
getRepoVar
::
HasNodeStory
env
err
m
=>
ListId
->
m
(
MVar
NodeListStory
)
getRepoVar
l
=
do
f
<-
getNodeListStory
v
<-
liftBase
$
f
l
pure
v
getNodeListStory
::
HasNodeStory
env
err
m
=>
m
(
NodeId
->
IO
(
MVar
NodeListStory
))
...
...
src/Gargantext/API/Ngrams/Types.hs
View file @
dfb77185
...
...
@@ -532,6 +532,7 @@ instance FromField (PatchMap TableNgrams.NgramsType (PatchMap NodeId NgramsTable
type
instance
ConflictResolution
NgramsTablePatch
=
NgramsTerm
->
ConflictResolutionNgramsPatch
type
PatchedNgramsTablePatch
=
Map
NgramsTerm
PatchedNgramsPatch
-- ~ Patched (PatchMap NgramsTerm NgramsPatch)
type
instance
Patched
NgramsTablePatch
=
PatchedNgramsTablePatch
...
...
@@ -675,17 +676,13 @@ data Repo s p = Repo
}
deriving
(
Generic
,
Show
)
-- | TO REMOVE
type
NgramsRepo
=
Repo
NgramsState
NgramsStatePatch
type
NgramsState
=
Map
TableNgrams
.
NgramsType
(
Map
NodeId
NgramsTableMap
)
type
NgramsStatePatch
=
PatchMap
TableNgrams
.
NgramsType
(
PatchMap
NodeId
NgramsTablePatch
)
----------------------------------------------------------------------
instance
(
FromJSON
s
,
FromJSON
p
)
=>
FromJSON
(
Repo
s
p
)
where
parseJSON
=
genericParseJSON
$
unPrefix
"_r_"
...
...
src/Gargantext/Core/NodeStory.hs
View file @
dfb77185
...
...
@@ -26,6 +26,7 @@ import Data.Aeson hiding ((.=))
import
qualified
Data.List
as
List
import
Data.Map
as
Map
import
Data.Monoid
import
Data.Semigroup
import
GHC.Generics
(
Generic
)
import
Gargantext.API.Ngrams.Types
import
Gargantext.Core.Types
(
NodeId
)
...
...
@@ -206,12 +207,18 @@ instance (Serialise s, Serialise p) => Serialise (Archive s p)
-- TODO Semigroup instance for unions
type
NodeListStory
=
NodeStory
NgramsState'
NgramsStatePatch'
type
ArchiveList
=
Archive
NgramsState'
NgramsStatePatch'
type
NgramsState'
=
Map
TableNgrams
.
NgramsType
NgramsTableMap
type
NgramsStatePatch'
=
PatchMap
TableNgrams
.
NgramsType
NgramsTablePatch
instance
Serialise
NgramsStatePatch'
-- TODO check this
instance
(
Semigroup
s
,
Semigroup
p
)
=>
Semigroup
(
Archive
s
p
)
where
(
<>
)
(
Archive
_v
_s
p
)
(
Archive
v'
s'
p'
)
=
Archive
v'
s'
(
p'
<>
p
)
instance
Monoid
(
Archive
NgramsState'
NgramsStatePatch'
)
where
mempty
=
Archive
0
mempty
[]
instance
(
FromJSON
s
,
FromJSON
p
)
=>
FromJSON
(
Archive
s
p
)
where
parseJSON
=
genericParseJSON
$
unPrefix
"_a_"
...
...
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