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
85f14511
Commit
85f14511
authored
Dec 03, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NGRAMS TABLE] refactor tableNgramsPull and expose listNgramsChangedSince
parent
08aa087f
Pipeline
#637
canceled with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
10 deletions
+24
-10
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+24
-10
No files found.
src/Gargantext/API/Ngrams.hs
View file @
85f14511
...
@@ -78,6 +78,11 @@ module Gargantext.API.Ngrams
...
@@ -78,6 +78,11 @@ module Gargantext.API.Ngrams
,
RepoCmdM
,
RepoCmdM
,
QueryParamR
,
QueryParamR
,
TODO
(
..
)
,
TODO
(
..
)
-- Internals
,
getNgramsTableMap
,
tableNgramsPull
,
tableNgramsPut
)
)
where
where
...
@@ -103,7 +108,7 @@ import Data.Map.Strict (Map)
...
@@ -103,7 +108,7 @@ import Data.Map.Strict (Map)
import
qualified
Data.Set
as
Set
import
qualified
Data.Set
as
Set
import
Control.Category
((
>>>
))
import
Control.Category
((
>>>
))
import
Control.Concurrent
import
Control.Concurrent
import
Control.Lens
(
makeLenses
,
makePrisms
,
Getter
,
Iso
'
,
iso
,
from
,
(
.~
),
(
?=
),
(
#
),
to
,
folded
,
{-withIndex, ifolded,-}
view
,
use
,
(
^.
),
(
^..
),
(
^?
),
(
+~
),
(
%~
),
(
%=
),
sumOf
,
at
,
_Just
,
Each
(
..
),
itraverse_
,
both
,
forOf_
,
(
%%~
),
(
?~
))
import
Control.Lens
(
makeLenses
,
makePrisms
,
Getter
,
Iso
'
,
iso
,
from
,
(
.~
),
(
?=
),
(
#
),
to
,
folded
,
{-withIndex, ifolded,-}
view
,
use
,
(
^.
),
(
^..
),
(
^?
),
(
+~
),
(
%~
),
(
%=
),
sumOf
,
at
,
_Just
,
Each
(
..
),
itraverse_
,
both
,
forOf_
,
(
%%~
),
(
?~
)
,
mapped
)
import
Control.Monad.Error.Class
(
MonadError
)
import
Control.Monad.Error.Class
(
MonadError
)
import
Control.Monad.Reader
import
Control.Monad.Reader
import
Control.Monad.State
import
Control.Monad.State
...
@@ -857,6 +862,20 @@ tableNgramsPost :: RepoCmdM env err m => TabType -> NodeId -> Maybe ListType ->
...
@@ -857,6 +862,20 @@ tableNgramsPost :: RepoCmdM env err m => TabType -> NodeId -> Maybe ListType ->
tableNgramsPost
tabType
listId
mayList
=
tableNgramsPost
tabType
listId
mayList
=
putListNgrams
listId
(
ngramsTypeFromTabType
tabType
)
.
fmap
(
newNgramsElement
mayList
)
putListNgrams
listId
(
ngramsTypeFromTabType
tabType
)
.
fmap
(
newNgramsElement
mayList
)
tableNgramsPull
::
RepoCmdM
env
err
m
=>
ListId
->
NgramsType
->
Version
->
m
(
Versioned
NgramsTablePatch
)
tableNgramsPull
listId
ngramsType
p_version
=
do
var
<-
view
repoVar
r
<-
liftIO
$
readMVar
var
let
q
=
mconcat
$
take
(
r
^.
r_version
-
p_version
)
(
r
^.
r_history
)
q_table
=
q
^.
_PatchMap
.
at
ngramsType
.
_Just
.
_PatchMap
.
at
listId
.
_Just
pure
(
Versioned
(
r
^.
r_version
)
q_table
)
-- Apply the given patch to the DB and returns the patch to be applied on the
-- Apply the given patch to the DB and returns the patch to be applied on the
-- client.
-- client.
-- TODO-ACCESS check
-- TODO-ACCESS check
...
@@ -867,15 +886,7 @@ tableNgramsPut :: (HasInvalidError err, RepoCmdM env err m)
...
@@ -867,15 +886,7 @@ tableNgramsPut :: (HasInvalidError err, RepoCmdM env err m)
tableNgramsPut
tabType
listId
(
Versioned
p_version
p_table
)
tableNgramsPut
tabType
listId
(
Versioned
p_version
p_table
)
|
p_table
==
mempty
=
do
|
p_table
==
mempty
=
do
let
ngramsType
=
ngramsTypeFromTabType
tabType
let
ngramsType
=
ngramsTypeFromTabType
tabType
tableNgramsPull
listId
ngramsType
p_version
var
<-
view
repoVar
r
<-
liftIO
$
readMVar
var
let
q
=
mconcat
$
take
(
r
^.
r_version
-
p_version
)
(
r
^.
r_history
)
q_table
=
q
^.
_PatchMap
.
at
ngramsType
.
_Just
.
_PatchMap
.
at
listId
.
_Just
pure
(
Versioned
(
r
^.
r_version
)
q_table
)
|
otherwise
=
do
|
otherwise
=
do
let
ngramsType
=
ngramsTypeFromTabType
tabType
let
ngramsType
=
ngramsTypeFromTabType
tabType
...
@@ -1157,3 +1168,6 @@ apiNgramsTableDoc dId = getTableNgramsDoc dId
...
@@ -1157,3 +1168,6 @@ apiNgramsTableDoc dId = getTableNgramsDoc dId
-- > add new ngrams in database (TODO AD)
-- > add new ngrams in database (TODO AD)
-- > index all the corpus accordingly (TODO AD)
-- > index all the corpus accordingly (TODO AD)
listNgramsChangedSince
::
RepoCmdM
env
err
m
=>
ListId
->
NgramsType
->
Version
->
m
(
Versioned
Bool
)
listNgramsChangedSince
listId
ngramsType
version
=
tableNgramsPull
listId
ngramsType
version
&
mapped
.
v_data
%~
(
==
mempty
)
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