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
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
Christian Merten
haskell-gargantext
Commits
0c970913
Commit
0c970913
authored
Sep 08, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
[FIX] merge with current dev
parents
a2a48b8c
f003143f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
150 additions
and
61 deletions
+150
-61
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+141
-57
List.hs
src/Gargantext/API/Ngrams/List.hs
+1
-0
Types.hs
src/Gargantext/Database/Action/Flow/Types.hs
+2
-0
stack.yaml
stack.yaml
+6
-4
No files found.
src/Gargantext/API/Ngrams.hs
View file @
0c970913
...
@@ -27,14 +27,14 @@ module Gargantext.API.Ngrams
...
@@ -27,14 +27,14 @@ module Gargantext.API.Ngrams
(
TableNgramsApi
(
TableNgramsApi
,
TableNgramsApiGet
,
TableNgramsApiGet
,
TableNgramsApiPut
,
TableNgramsApiPut
,
TableNgramsApiPost
--
, TableNgramsApiPost
,
getTableNgrams
,
getTableNgrams
,
setListNgrams
,
setListNgrams
,
rmListNgrams
--, rmListNgrams TODO fix before exporting
,
putListNgrams
,
putListNgrams
,
putListNgrams'
--
, putListNgrams'
,
tableNgramsPost
--
, tableNgramsPost
,
apiNgramsTableCorpus
,
apiNgramsTableCorpus
,
apiNgramsTableDoc
,
apiNgramsTableDoc
...
@@ -100,7 +100,7 @@ import Control.Monad.Trans.Control (MonadBaseControl)
...
@@ -100,7 +100,7 @@ import Control.Monad.Trans.Control (MonadBaseControl)
import
Data.Aeson
hiding
((
.=
))
import
Data.Aeson
hiding
((
.=
))
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Aeson.TH
(
deriveJSON
)
import
qualified
Data.Aeson.Text
as
DAT
import
qualified
Data.Aeson.Text
as
DAT
import
Data.Either
(
Either
(
Left
))
import
Data.Either
(
Either
(
..
))
import
Data.Foldable
import
Data.Foldable
import
qualified
Data.HashMap.Strict.InsOrd
as
InsOrdHashMap
import
qualified
Data.HashMap.Strict.InsOrd
as
InsOrdHashMap
import
qualified
Data.List
as
List
import
qualified
Data.List
as
List
...
@@ -110,7 +110,9 @@ import qualified Data.Map.Strict.Patch as PM
...
@@ -110,7 +110,9 @@ import qualified Data.Map.Strict.Patch as PM
import
Data.Maybe
(
fromMaybe
)
import
Data.Maybe
(
fromMaybe
)
import
Data.Monoid
import
Data.Monoid
import
Data.Ord
(
Down
(
..
))
import
Data.Ord
(
Down
(
..
))
import
Data.Patch.Class
(
Replace
,
replace
,
Action
(
act
),
Applicable
(
..
),
Composable
(
..
),
Transformable
(
..
),
PairPatch
(
..
),
Patched
,
ConflictResolution
,
ConflictResolutionReplace
,
ours
)
import
Data.Patch.Class
(
Replace
,
replace
,
Action
(
act
),
Group
,
Applicable
(
..
),
Composable
(
..
),
Transformable
(
..
),
PairPatch
(
..
),
Patched
,
ConflictResolution
,
ConflictResolutionReplace
,
ours
,
MaybePatch
(
Mod
),
unMod
,
old
,
new
)
import
Data.Set
(
Set
)
import
Data.Set
(
Set
)
import
qualified
Data.Set
as
S
import
qualified
Data.Set
as
S
import
qualified
Data.Set
as
Set
import
qualified
Data.Set
as
Set
...
@@ -126,7 +128,7 @@ import Servant hiding (Patch)
...
@@ -126,7 +128,7 @@ import Servant hiding (Patch)
import
System.Clock
(
getTime
,
TimeSpec
,
Clock
(
..
))
import
System.Clock
(
getTime
,
TimeSpec
,
Clock
(
..
))
import
System.FileLock
(
FileLock
)
import
System.FileLock
(
FileLock
)
import
System.IO
(
stderr
)
import
System.IO
(
stderr
)
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck
(
elements
,
frequency
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
import
Prelude
(
error
)
import
Prelude
(
error
)
...
@@ -455,7 +457,7 @@ type PatchMap = PM.PatchMap
...
@@ -455,7 +457,7 @@ type PatchMap = PM.PatchMap
newtype
PatchMSet
a
=
PatchMSet
(
PatchMap
a
AddRem
)
newtype
PatchMSet
a
=
PatchMSet
(
PatchMap
a
AddRem
)
deriving
(
Eq
,
Show
,
Generic
,
Validity
,
Semigroup
,
Monoid
,
deriving
(
Eq
,
Show
,
Generic
,
Validity
,
Semigroup
,
Monoid
,
Group
,
Transformable
,
Composable
)
Transformable
,
Composable
)
type
ConflictResolutionPatchMSet
a
=
a
->
ConflictResolutionReplace
(
Maybe
()
)
type
ConflictResolutionPatchMSet
a
=
a
->
ConflictResolutionReplace
(
Maybe
()
)
...
@@ -519,9 +521,12 @@ instance ToSchema a => ToSchema (Replace a) where
...
@@ -519,9 +521,12 @@ instance ToSchema a => ToSchema (Replace a) where
&
required
.~
[
"old"
,
"new"
]
&
required
.~
[
"old"
,
"new"
]
data
NgramsPatch
=
data
NgramsPatch
=
Ngrams
Patch
{
_patch_children
::
PatchMSet
NgramsTerm
Ngrams
Mod
{
_patch_children
::
PatchMSet
NgramsTerm
,
_patch_list
::
Replace
ListType
-- TODO Map UserId ListType
,
_patch_list
::
Replace
ListType
-- TODO Map UserId ListType
}
}
|
NgramsRpl
{
_patch_old
::
Maybe
NgramsRepoElement
,
_patch_new
::
Maybe
NgramsRepoElement
}
deriving
(
Eq
,
Show
,
Generic
)
deriving
(
Eq
,
Show
,
Generic
)
deriveJSON
(
unPrefix
"_"
)
''
N
gramsPatch
deriveJSON
(
unPrefix
"_"
)
''
N
gramsPatch
...
@@ -531,16 +536,31 @@ instance ToSchema NgramsPatch where
...
@@ -531,16 +536,31 @@ instance ToSchema NgramsPatch where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"_"
)
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"_"
)
instance
Arbitrary
NgramsPatch
where
instance
Arbitrary
NgramsPatch
where
arbitrary
=
NgramsPatch
<$>
arbitrary
<*>
(
replace
<$>
arbitrary
<*>
arbitrary
)
arbitrary
=
frequency
[
(
9
,
NgramsMod
<$>
arbitrary
<*>
(
replace
<$>
arbitrary
<*>
arbitrary
))
,
(
1
,
NgramsRpl
<$>
arbitrary
<*>
arbitrary
)
]
instance
Serialise
NgramsPatch
instance
Serialise
NgramsPatch
instance
Serialise
(
Replace
ListType
)
instance
Serialise
(
Replace
ListType
)
instance
Serialise
ListType
instance
Serialise
ListType
type
NgramsPatchIso
=
PairPatch
(
PatchMSet
NgramsTerm
)
(
Replace
ListType
)
type
NgramsPatchIso
=
MaybePatch
NgramsRepoElement
(
PairPatch
(
PatchMSet
NgramsTerm
)
(
Replace
ListType
))
-- MaybePatch (MSet NgramsTerm, ListType) (PairPatch (PatchMSet NgramsTerm) (Replace ListType))
_NgramsPatch
::
Iso'
NgramsPatch
NgramsPatchIso
_NgramsPatch
::
Iso'
NgramsPatch
NgramsPatchIso
_NgramsPatch
=
iso
(
\
(
NgramsPatch
c
l
)
->
c
:*:
l
)
(
\
(
c
:*:
l
)
->
NgramsPatch
c
l
)
_NgramsPatch
=
iso
unwrap
wrap
where
unwrap
(
NgramsMod
c
l
)
=
Mod
$
PairPatch
(
c
,
l
)
unwrap
(
NgramsRpl
o
n
)
=
replace
o
n
wrap
x
=
case
unMod
x
of
Just
(
PairPatch
(
c
,
l
))
->
NgramsMod
c
l
Nothing
->
NgramsRpl
(
x
^?
old
.
_Just
)
(
x
^?
new
.
_Just
)
_NgramsRepoElement
::
Iso'
NgramsRepoElement
(
MSet
NgramsTerm
,
ListType
)
_NgramsRepoElement
=
undefined
-- TODO
instance
Semigroup
NgramsPatch
where
instance
Semigroup
NgramsPatch
where
p
<>
q
=
_NgramsPatch
#
(
p
^.
_NgramsPatch
<>
q
^.
_NgramsPatch
)
p
<>
q
=
_NgramsPatch
#
(
p
^.
_NgramsPatch
<>
q
^.
_NgramsPatch
)
...
@@ -561,28 +581,67 @@ instance Transformable NgramsPatch where
...
@@ -561,28 +581,67 @@ instance Transformable NgramsPatch where
(
p'
,
q'
)
=
transformWith
conflict
(
p
^.
_NgramsPatch
)
(
q
^.
_NgramsPatch
)
(
p'
,
q'
)
=
transformWith
conflict
(
p
^.
_NgramsPatch
)
(
q
^.
_NgramsPatch
)
type
ConflictResolutionNgramsPatch
=
type
ConflictResolutionNgramsPatch
=
(
ConflictResolutionPatchMSet
NgramsTerm
(
ConflictResolutionReplace
(
Maybe
NgramsRepoElement
)
,
(
ConflictResolutionPatchMSet
NgramsTerm
,
ConflictResolutionReplace
ListType
,
ConflictResolutionReplace
ListType
)
)
,
(
Bool
,
Bool
)
)
type
instance
ConflictResolution
NgramsPatch
=
type
instance
ConflictResolution
NgramsPatch
=
ConflictResolutionNgramsPatch
ConflictResolutionNgramsPatch
type
PatchedNgramsPatch
=
(
Set
NgramsTerm
,
ListType
)
type
PatchedNgramsPatch
=
Maybe
NgramsRepoElement
-- ~ Patched NgramsPatchIso
-- ~ Patched NgramsPatchIso
type
instance
Patched
NgramsPatch
=
PatchedNgramsPatch
type
instance
Patched
NgramsPatch
=
PatchedNgramsPatch
{-
instance Applicable NgramsPatch NgramsRepoElement where
applicable (NgramsRpl o _) nre =
check (o == Just nre) "NgramsPatch: Applying a value different than the *old* value of a Rpl patch"
applicable (NgramsMod c l) nre =
applicable c (nre ^. nre_children) <>
applicable l (nre ^. nre_list)
instance Action NgramsPatch NgramsRepoElement where
act (NgramsMod c l) m = act' <$> m
where
act' = (nre_children %~ act c)
. (nre_list %~ act l)
act (NgramsRpl _ n) _ = n
-}
instance
Applicable
(
PairPatch
(
PatchMSet
NgramsTerm
)
(
Replace
ListType
))
NgramsRepoElement
where
applicable
(
PairPatch
(
c
,
l
))
n
=
applicable
c
(
n
^.
nre_children
)
<>
applicable
l
(
n
^.
nre_list
)
instance
Action
(
PairPatch
(
PatchMSet
NgramsTerm
)
(
Replace
ListType
))
NgramsRepoElement
where
act
(
PairPatch
(
c
,
l
))
=
(
nre_children
%~
act
c
)
.
(
nre_list
%~
act
l
)
--instance Applicable (PairPatch (PatchMSet NgramsTerm) (Replace ListType)) (Maybe NgramsRepoElement) where
-- applicable = _H
instance
Applicable
NgramsPatchIso
(
Maybe
(
MSet
NgramsTerm
,
ListType
))
where
applicable
p
n
=
applicable
p
(
n
^?
_Just
.
from
_NgramsRepoElement
)
instance
Applicable
NgramsPatch
(
Maybe
NgramsRepoElement
)
where
instance
Applicable
NgramsPatch
(
Maybe
NgramsRepoElement
)
where
applicable
p
n
=
applicable
(
p
^.
_NgramsPatch
)
(
n
^?
_Just
.
_NgramsRepoElement
)
{-
applicable (NgramsRpl o _) nre =
check (o == Just nre) "NgramsPatch: Applying a value different than the *old* value of a Rpl patch"
applicable p Nothing = check (p == mempty) "NgramsPatch should be empty here"
applicable p Nothing = check (p == mempty) "NgramsPatch should be empty here"
applicable p (Just nre) =
applicable p (Just nre) =
applicable (p ^. patch_children) (nre ^. nre_children) <>
applicable (p ^. patch_children) (nre ^. nre_children) <>
applicable (p ^. patch_list) (nre ^. nre_list)
applicable (p ^. patch_list) (nre ^. nre_list)
-}
instance
Action
NgramsPatch
NgramsRepoElement
where
act
p
=
(
nre_children
%~
act
(
p
^.
patch_children
))
.
(
nre_list
%~
act
(
p
^.
patch_list
))
instance
Action
NgramsPatch
(
Maybe
NgramsRepoElement
)
where
instance
Action
NgramsPatch
(
Maybe
NgramsRepoElement
)
where
act
=
fmap
.
act
act
p
m
=
act
(
p
^.
_NgramsPatch
)
m
{-
act (NgramsMod c l) m = act' <$> m
where
act' = (nre_children %~ act c)
. (nre_list %~ act l)
act (NgramsRpl _ n) _ = n
-}
newtype
NgramsTablePatch
=
NgramsTablePatch
(
PatchMap
NgramsTerm
NgramsPatch
)
newtype
NgramsTablePatch
=
NgramsTablePatch
(
PatchMap
NgramsTerm
NgramsPatch
)
deriving
(
Eq
,
Show
,
Generic
,
ToJSON
,
FromJSON
,
Semigroup
,
Monoid
,
Validity
,
Transformable
)
deriving
(
Eq
,
Show
,
Generic
,
ToJSON
,
FromJSON
,
Semigroup
,
Monoid
,
Validity
,
Transformable
)
...
@@ -821,7 +880,10 @@ ngramsStatePatchConflictResolution
...
@@ -821,7 +880,10 @@ ngramsStatePatchConflictResolution
->
NgramsTerm
->
NgramsTerm
->
ConflictResolutionNgramsPatch
->
ConflictResolutionNgramsPatch
ngramsStatePatchConflictResolution
_ngramsType
_nodeId
_ngramsTerm
ngramsStatePatchConflictResolution
_ngramsType
_nodeId
_ngramsTerm
=
(
const
ours
,
ours
)
=
(
ours
,
(
const
ours
,
ours
),
(
False
,
False
))
-- ^------^------- they mean that Mod has always priority.
--(True, False) <- would mean priority to the left (same as ours).
-- undefined {- TODO think this through -}, listTypeConflictResolution)
-- undefined {- TODO think this through -}, listTypeConflictResolution)
-- Current state:
-- Current state:
...
@@ -865,6 +927,7 @@ addListNgrams listId ngramsType nes = do
...
@@ -865,6 +927,7 @@ addListNgrams listId ngramsType nes = do
m = Map.fromList $ (\n -> (n ^. ne_ngrams, n)) <$> nes
m = Map.fromList $ (\n -> (n ^. ne_ngrams, n)) <$> nes
-}
-}
-- UNSAFE
rmListNgrams
::
RepoCmdM
env
err
m
rmListNgrams
::
RepoCmdM
env
err
m
=>
ListId
=>
ListId
->
TableNgrams
.
NgramsType
->
TableNgrams
.
NgramsType
...
@@ -873,6 +936,7 @@ rmListNgrams l nt = setListNgrams l nt mempty
...
@@ -873,6 +936,7 @@ rmListNgrams l nt = setListNgrams l nt mempty
-- | TODO: incr the Version number
-- | TODO: incr the Version number
-- && should use patch
-- && should use patch
-- UNSAFE
setListNgrams
::
RepoCmdM
env
err
m
setListNgrams
::
RepoCmdM
env
err
m
=>
NodeId
=>
NodeId
->
TableNgrams
.
NgramsType
->
TableNgrams
.
NgramsType
...
@@ -890,10 +954,12 @@ setListNgrams listId ngramsType ns = do
...
@@ -890,10 +954,12 @@ setListNgrams listId ngramsType ns = do
)
)
saveRepo
saveRepo
-- NOTE
-- This is no longer part of the API.
-- This function is maintained for its usage in Database.Action.Flow.List.
-- If the given list of ngrams elements contains ngrams already in
-- If the given list of ngrams elements contains ngrams already in
-- the repo, they will be ignored.
-- the repo, they will be ignored.
putListNgrams
::
RepoCmdM
env
err
m
putListNgrams
::
(
HasInvalidError
err
,
RepoCmdM
env
err
m
)
=>
NodeId
=>
NodeId
->
TableNgrams
.
NgramsType
->
TableNgrams
.
NgramsType
->
[
NgramsElement
]
->
m
()
->
[
NgramsElement
]
->
m
()
...
@@ -902,19 +968,27 @@ putListNgrams nodeId ngramsType nes = putListNgrams' nodeId ngramsType m
...
@@ -902,19 +968,27 @@ putListNgrams nodeId ngramsType nes = putListNgrams' nodeId ngramsType m
where
where
m
=
Map
.
fromList
$
map
(
\
n
->
(
n
^.
ne_ngrams
,
ngramsElementToRepo
n
))
nes
m
=
Map
.
fromList
$
map
(
\
n
->
(
n
^.
ne_ngrams
,
ngramsElementToRepo
n
))
nes
putListNgrams'
::
RepoCmdM
env
err
m
putListNgrams'
::
(
HasInvalidError
err
,
RepoCmdM
env
err
m
)
=>
NodeId
=>
NodeId
->
TableNgrams
.
NgramsType
->
TableNgrams
.
NgramsType
->
Map
NgramsTerm
NgramsRepoElement
->
Map
NgramsTerm
NgramsRepoElement
->
m
()
->
m
()
putListNgrams'
nodeId
ngramsType
ns
=
do
putListNgrams'
nodeId
ngramsType
ns
=
do
-- printDebug "[putLictNgrams'] nodeId" nodeId
printDebug
"[putLictNgrams'] nodeId"
nodeId
-- printDebug "[putLictNgrams'] ngramsType" ngramsType
printDebug
"[putLictNgrams'] ngramsType"
ngramsType
-- printDebug "[putListNgrams'] ns" ns
printDebug
"[putListNgrams'] ns"
ns
-- commitStatePatch ()
let
p1
=
NgramsTablePatch
.
PM
.
fromMap
$
NgramsRpl
Nothing
.
Just
<$>
ns
(
p0
,
p0_validity
)
=
PM
.
singleton
nodeId
p1
(
p
,
p_validity
)
=
PM
.
singleton
ngramsType
p0
-- assertValid p1_validity
assertValid
p0_validity
assertValid
p_validity
var
<-
view
repoVar
var
<-
view
repoVar
liftBase
$
modifyMVar_
var
$
\
r
->
do
liftBase
$
modifyMVar_
var
$
\
r
->
do
pure
$
r
&
r_version
+~
1
pure
$
r
&
r_version
+~
1
&
r_history
%~
(
mempty
:
)
&
r_history
%~
(
p
:
)
&
r_state
.
at
ngramsType
%~
&
r_state
.
at
ngramsType
%~
(
Just
.
(
Just
.
(
at
nodeId
%~
(
at
nodeId
%~
...
@@ -928,6 +1002,7 @@ putListNgrams' nodeId ngramsType ns = do
...
@@ -928,6 +1002,7 @@ putListNgrams' nodeId ngramsType ns = do
saveRepo
saveRepo
{-
-- TODO-ACCESS check
-- TODO-ACCESS check
tableNgramsPost :: RepoCmdM env err m
tableNgramsPost :: RepoCmdM env err m
=> TabType
=> TabType
...
@@ -936,6 +1011,7 @@ tableNgramsPost :: RepoCmdM env err m
...
@@ -936,6 +1011,7 @@ tableNgramsPost :: RepoCmdM env err m
-> [NgramsTerm] -> m ()
-> [NgramsTerm] -> m ()
tableNgramsPost tabType nodeId mayList =
tableNgramsPost tabType nodeId mayList =
putListNgrams nodeId (ngramsTypeFromTabType tabType) . fmap (newNgramsElement mayList)
putListNgrams nodeId (ngramsTypeFromTabType tabType) . fmap (newNgramsElement mayList)
-}
currentVersion
::
RepoCmdM
env
err
m
currentVersion
::
RepoCmdM
env
err
m
=>
m
Version
=>
m
Version
...
@@ -944,6 +1020,34 @@ currentVersion = do
...
@@ -944,6 +1020,34 @@ currentVersion = do
r
<-
liftBase
$
readMVar
var
r
<-
liftBase
$
readMVar
var
pure
$
r
^.
r_version
pure
$
r
^.
r_version
-- tableNgramsPut :: (HasInvalidError err, RepoCmdM env err m)
commitStatePatch
::
RepoCmdM
env
err
m
=>
Versioned
NgramsStatePatch
->
m
(
Versioned
NgramsStatePatch
)
commitStatePatch
(
Versioned
p_version
p
)
=
do
var
<-
view
repoVar
vq'
<-
liftBase
$
modifyMVar
var
$
\
r
->
do
let
q
=
mconcat
$
take
(
r
^.
r_version
-
p_version
)
(
r
^.
r_history
)
(
p'
,
q'
)
=
transformWith
ngramsStatePatchConflictResolution
p
q
r'
=
r
&
r_version
+~
1
&
r_state
%~
act
p'
&
r_history
%~
(
p'
:
)
{-
-- Ideally we would like to check these properties. However:
-- * They should be checked only to debug the code. The client data
-- should be able to trigger these.
-- * What kind of error should they throw (we are in IO here)?
-- * Should we keep modifyMVar?
-- * Should we throw the validation in an Exception, catch it around
-- modifyMVar and throw it back as an Error?
assertValid $ transformable p q
assertValid $ applicable p' (r ^. r_state)
-}
pure
(
r'
,
Versioned
(
r'
^.
r_version
)
q'
)
saveRepo
pure
vq'
tableNgramsPull
::
RepoCmdM
env
err
m
tableNgramsPull
::
RepoCmdM
env
err
m
=>
ListId
=>
ListId
->
TableNgrams
.
NgramsType
->
TableNgrams
.
NgramsType
...
@@ -979,30 +1083,8 @@ tableNgramsPut tabType listId (Versioned p_version p_table)
...
@@ -979,30 +1083,8 @@ tableNgramsPut tabType listId (Versioned p_version p_table)
assertValid
p0_validity
assertValid
p0_validity
assertValid
p_validity
assertValid
p_validity
var
<-
view
repoVar
commitStatePatch
(
Versioned
p_version
p
)
vq'
<-
liftBase
$
modifyMVar
var
$
\
r
->
do
<&>
v_data
%~
(
view
(
_PatchMap
.
at
ngramsType
.
_Just
.
_PatchMap
.
at
listId
.
_Just
))
let
q
=
mconcat
$
take
(
r
^.
r_version
-
p_version
)
(
r
^.
r_history
)
(
p'
,
q'
)
=
transformWith
ngramsStatePatchConflictResolution
p
q
r'
=
r
&
r_version
+~
1
&
r_state
%~
act
p'
&
r_history
%~
(
p'
:
)
q'_table
=
q'
^.
_PatchMap
.
at
ngramsType
.
_Just
.
_PatchMap
.
at
listId
.
_Just
{-
-- Ideally we would like to check these properties. However:
-- * They should be checked only to debug the code. The client data
-- should be able to trigger these.
-- * What kind of error should they throw (we are in IO here)?
-- * Should we keep modifyMVar?
-- * Should we throw the validation in an Exception, catch it around
-- modifyMVar and throw it back as an Error?
assertValid $ transformable p q
assertValid $ applicable p' (r ^. r_state)
-}
pure
(
r'
,
Versioned
(
r'
^.
r_version
)
q'_table
)
saveRepo
pure
vq'
mergeNgramsElement
::
NgramsRepoElement
->
NgramsRepoElement
->
NgramsRepoElement
mergeNgramsElement
::
NgramsRepoElement
->
NgramsRepoElement
->
NgramsRepoElement
mergeNgramsElement
_neOld
neNew
=
neNew
mergeNgramsElement
_neOld
neNew
=
neNew
...
@@ -1221,12 +1303,14 @@ type TableNgramsApiPut = Summary " Table Ngrams API Change"
...
@@ -1221,12 +1303,14 @@ type TableNgramsApiPut = Summary " Table Ngrams API Change"
:>
ReqBody
'[
J
SON
]
(
Versioned
NgramsTablePatch
)
:>
ReqBody
'[
J
SON
]
(
Versioned
NgramsTablePatch
)
:>
Put
'[
J
SON
]
(
Versioned
NgramsTablePatch
)
:>
Put
'[
J
SON
]
(
Versioned
NgramsTablePatch
)
{-
type TableNgramsApiPost = Summary " Table Ngrams API Adds new ngrams"
type TableNgramsApiPost = Summary " Table Ngrams API Adds new ngrams"
:> QueryParamR "ngramsType" TabType
:> QueryParamR "ngramsType" TabType
:> QueryParamR "list" ListId
:> QueryParamR "list" ListId
:> QueryParam "listType" ListType
:> QueryParam "listType" ListType
:> ReqBody '[JSON] [NgramsTerm]
:> ReqBody '[JSON] [NgramsTerm]
:> Post '[JSON] ()
:> Post '[JSON] ()
-}
type
RecomputeScoresNgramsApiGet
=
Summary
" Recompute scores for ngrams table"
type
RecomputeScoresNgramsApiGet
=
Summary
" Recompute scores for ngrams table"
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParamR
"ngramsType"
TabType
...
@@ -1240,7 +1324,7 @@ type TableNgramsApiGetVersion = Summary " Table Ngrams API Get Version"
...
@@ -1240,7 +1324,7 @@ type TableNgramsApiGetVersion = Summary " Table Ngrams API Get Version"
type
TableNgramsApi
=
TableNgramsApiGet
type
TableNgramsApi
=
TableNgramsApiGet
:<|>
TableNgramsApiPut
:<|>
TableNgramsApiPut
:<|>
TableNgramsApiPost
--
:<|> TableNgramsApiPost
:<|>
RecomputeScoresNgramsApiGet
:<|>
RecomputeScoresNgramsApiGet
:<|>
"version"
:>
TableNgramsApiGetVersion
:<|>
"version"
:>
TableNgramsApiGetVersion
...
@@ -1297,7 +1381,7 @@ apiNgramsTableCorpus :: ( RepoCmdM env err m
...
@@ -1297,7 +1381,7 @@ apiNgramsTableCorpus :: ( RepoCmdM env err m
=>
NodeId
->
ServerT
TableNgramsApi
m
=>
NodeId
->
ServerT
TableNgramsApi
m
apiNgramsTableCorpus
cId
=
getTableNgramsCorpus
cId
apiNgramsTableCorpus
cId
=
getTableNgramsCorpus
cId
:<|>
tableNgramsPut
:<|>
tableNgramsPut
:<|>
tableNgramsPost
--
:<|> tableNgramsPost
:<|>
scoresRecomputeTableNgrams
cId
:<|>
scoresRecomputeTableNgrams
cId
:<|>
getTableNgramsVersion
cId
:<|>
getTableNgramsVersion
cId
...
@@ -1310,7 +1394,7 @@ apiNgramsTableDoc :: ( RepoCmdM env err m
...
@@ -1310,7 +1394,7 @@ apiNgramsTableDoc :: ( RepoCmdM env err m
=>
DocId
->
ServerT
TableNgramsApi
m
=>
DocId
->
ServerT
TableNgramsApi
m
apiNgramsTableDoc
dId
=
getTableNgramsDoc
dId
apiNgramsTableDoc
dId
=
getTableNgramsDoc
dId
:<|>
tableNgramsPut
:<|>
tableNgramsPut
:<|>
tableNgramsPost
--
:<|> tableNgramsPost
:<|>
scoresRecomputeTableNgrams
dId
:<|>
scoresRecomputeTableNgrams
dId
:<|>
getTableNgramsVersion
dId
:<|>
getTableNgramsVersion
dId
-- > add new ngrams in database (TODO AD)
-- > add new ngrams in database (TODO AD)
...
...
src/Gargantext/API/Ngrams/List.hs
View file @
0c970913
...
@@ -74,6 +74,7 @@ get' lId = fromList
...
@@ -74,6 +74,7 @@ get' lId = fromList
------------------------------------------------------------------------
------------------------------------------------------------------------
-- TODO : purge list
-- TODO : purge list
-- TODO talk
post
::
FlowCmdM
env
err
m
post
::
FlowCmdM
env
err
m
=>
ListId
=>
ListId
->
NgramsList
->
NgramsList
...
...
src/Gargantext/Database/Action/Flow/Types.hs
View file @
0c970913
...
@@ -20,6 +20,7 @@ module Gargantext.Database.Action.Flow.Types
...
@@ -20,6 +20,7 @@ module Gargantext.Database.Action.Flow.Types
where
where
import
Data.Aeson
(
ToJSON
)
import
Data.Aeson
(
ToJSON
)
import
Gargantext.Core.Types
(
HasInvalidError
)
import
Gargantext.Core.Flow.Types
import
Gargantext.Core.Flow.Types
import
Gargantext.Core.Text
import
Gargantext.Core.Text
import
Gargantext.Core.Text.Terms
import
Gargantext.Core.Text.Terms
...
@@ -32,6 +33,7 @@ type FlowCmdM env err m =
...
@@ -32,6 +33,7 @@ type FlowCmdM env err m =
(
CmdM
env
err
m
(
CmdM
env
err
m
,
RepoCmdM
env
err
m
,
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasNodeError
err
,
HasInvalidError
err
,
HasRepoVar
env
,
HasRepoVar
env
)
)
...
...
stack.yaml
View file @
0c970913
...
@@ -3,6 +3,8 @@ flags: {}
...
@@ -3,6 +3,8 @@ flags: {}
extra-package-dbs
:
[]
extra-package-dbs
:
[]
packages
:
packages
:
-
.
-
.
-
'
deps/patches-class'
-
'
deps/patches-map'
#- 'deps/servant-job'
#- 'deps/servant-job'
#- 'deps/clustering-louvain'
#- 'deps/clustering-louvain'
...
@@ -42,16 +44,16 @@ extra-deps:
...
@@ -42,16 +44,16 @@ extra-deps:
-
git
:
https://gitlab.iscpif.fr/gargantext/crawlers/isidore.git
-
git
:
https://gitlab.iscpif.fr/gargantext/crawlers/isidore.git
commit
:
3db385e767d2100d8abe900833c6e7de3ac55e1b
commit
:
3db385e767d2100d8abe900833c6e7de3ac55e1b
#
#
-
git
:
https://gitlab.iscpif.fr/gargantext/patches-class
#
- git: https://gitlab.iscpif.fr/gargantext/patches-class
commit
:
746b4ce0af8f9e600d555ad7e5b2973a940cdad9
#
commit: 746b4ce0af8f9e600d555ad7e5b2973a940cdad9
#- git: https://github.com/delanoe/servant-job.git
#- git: https://github.com/delanoe/servant-job.git
#commit: 7a7b7100e6d132adb4c11b25b2128e6309690ac0
#commit: 7a7b7100e6d132adb4c11b25b2128e6309690ac0
-
git
:
https://github.com/np/servant-job.git
-
git
:
https://github.com/np/servant-job.git
commit
:
6487744c322baaa9229fdabd321a878a5b363c61
commit
:
6487744c322baaa9229fdabd321a878a5b363c61
-
git
:
https://gitlab.iscpif.fr/gargantext/clustering-louvain.git
-
git
:
https://gitlab.iscpif.fr/gargantext/clustering-louvain.git
commit
:
7d74f96dfea8e51fbab1793cc0429b2fe741f73d
commit
:
7d74f96dfea8e51fbab1793cc0429b2fe741f73d
-
git
:
https://github.com/np/patches-map
#
- git: https://github.com/np/patches-map
commit
:
8c6f38c4844ead53e664cf9c82ba461715dbe445
#
commit: 8c6f38c4844ead53e664cf9c82ba461715dbe445
-
git
:
https://github.com/delanoe/haskell-opaleye.git
#- opaleye-0.6.7002.0
-
git
:
https://github.com/delanoe/haskell-opaleye.git
#- opaleye-0.6.7002.0
commit
:
63ee65d974e9d20eaaf17a2e83652175988cbb79
commit
:
63ee65d974e9d20eaaf17a2e83652175988cbb79
-
git
:
https://github.com/delanoe/hsparql.git
-
git
:
https://github.com/delanoe/hsparql.git
...
...
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