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
Julien Moutinho
haskell-gargantext
Commits
80c9a609
Commit
80c9a609
authored
Feb 07, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[READING] proposal: keeping data consistency with database.
parent
4fafc5c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
6 deletions
+13
-6
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+12
-5
Flow.hs
src/Gargantext/Database/Flow.hs
+1
-1
No files found.
src/Gargantext/API/Ngrams.hs
View file @
80c9a609
...
@@ -34,6 +34,7 @@ add get
...
@@ -34,6 +34,7 @@ add get
module
Gargantext.API.Ngrams
module
Gargantext.API.Ngrams
where
where
--import Debug.Trace (trace)
import
Prelude
(
Enum
,
Bounded
,
Semigroup
(
..
),
minBound
,
maxBound
{-, round-}
,
error
)
import
Prelude
(
Enum
,
Bounded
,
Semigroup
(
..
),
minBound
,
maxBound
{-, round-}
,
error
)
-- import Gargantext.Database.Schema.User (UserId)
-- import Gargantext.Database.Schema.User (UserId)
import
Data.Functor
((
$>
))
import
Data.Functor
((
$>
))
...
@@ -45,6 +46,7 @@ import qualified Data.Map.Strict.Patch as PM
...
@@ -45,6 +46,7 @@ import qualified Data.Map.Strict.Patch as PM
import
Data.Monoid
import
Data.Monoid
--import Data.Semigroup
--import Data.Semigroup
import
Data.Set
(
Set
)
import
Data.Set
(
Set
)
import
qualified
Data.List
as
List
-- import Data.Maybe (isJust)
-- import Data.Maybe (isJust)
-- import Data.Tuple.Extra (first)
-- import Data.Tuple.Extra (first)
import
qualified
Data.Map.Strict
as
Map
import
qualified
Data.Map.Strict
as
Map
...
@@ -564,14 +566,14 @@ makeLenses ''Repo
...
@@ -564,14 +566,14 @@ makeLenses ''Repo
initRepo
::
Monoid
s
=>
Repo
s
p
initRepo
::
Monoid
s
=>
Repo
s
p
initRepo
=
Repo
1
mempty
[]
initRepo
=
Repo
1
mempty
[]
type
NgramsRepo
=
Repo
NgramsState
NgramsStatePatch
type
NgramsState
=
Map
ListId
(
Map
NgramsType
NgramsTableMap
)
type
NgramsState
=
Map
ListId
(
Map
NgramsType
NgramsTableMap
)
type
NgramsStatePatch
=
PatchMap
ListId
(
PatchMap
NgramsType
NgramsTablePatch
)
type
NgramsStatePatch
=
PatchMap
ListId
(
PatchMap
NgramsType
NgramsTablePatch
)
type
NgramsRepo
=
Repo
NgramsState
NgramsStatePatch
initMockRepo
::
NgramsRepo
initMockRepo
::
NgramsRepo
initMockRepo
=
Repo
1
s
[]
initMockRepo
=
Repo
1
s
[]
where
where
s
=
Map
.
singleton
1
s
=
Map
.
singleton
47254
$
Map
.
singleton
Ngrams
.
NgramsTerms
$
Map
.
singleton
Ngrams
.
NgramsTerms
$
Map
.
fromList
$
Map
.
fromList
[
(
n
^.
ne_ngrams
,
n
)
|
n
<-
mockTable
^.
_NgramsTable
]
[
(
n
^.
ne_ngrams
,
n
)
|
n
<-
mockTable
^.
_NgramsTable
]
...
@@ -628,7 +630,7 @@ insertNewListOfNgramsElements listId m = do
...
@@ -628,7 +630,7 @@ insertNewListOfNgramsElements listId m = do
m'
=
(
Map
.
fromList
.
fmap
(
\
n
->
(
n
^.
ne_ngrams
,
n
)))
<$>
m
m'
=
(
Map
.
fromList
.
fmap
(
\
n
->
(
n
^.
ne_ngrams
,
n
)))
<$>
m
-- 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
-- c
il
ent.
-- c
li
ent.
-- TODO:
-- TODO:
-- In this perliminary version the OT aspect is missing, therefore the version
-- In this perliminary version the OT aspect is missing, therefore the version
-- number is always 1 and the returned patch is always empty.
-- number is always 1 and the returned patch is always empty.
...
@@ -698,9 +700,14 @@ getTableNgrams cId maybeTabType maybeListId mlimit moffset = do
...
@@ -698,9 +700,14 @@ getTableNgrams cId maybeTabType maybeListId mlimit moffset = do
.
at
ngramsType
.
_Just
.
at
ngramsType
.
_Just
.
taking
limit_
(
dropping
offset_
each
)
.
taking
limit_
(
dropping
offset_
each
)
pure
$
Versioned
(
repo
^.
r_version
)
(
NgramsTable
ngrams
)
let
ngrams'
=
case
List
.
null
ngrams
of
True
->
[]
-- buildRepoFromDb (TODO sync with DB at shutdown)
False
->
ngrams
{-
pure
$
Versioned
(
repo
^.
r_version
)
(
NgramsTable
ngrams'
)
{-
buildRepoFromDb listId = do
ngramsTableDatas <-
ngramsTableDatas <-
Ngrams.getNgramsTableDb NodeDocument ngramsType (Ngrams.NgramsTableParam listId cId) limit_ offset_
Ngrams.getNgramsTableDb NodeDocument ngramsType (Ngrams.NgramsTableParam listId cId) limit_ offset_
...
...
src/Gargantext/Database/Flow.hs
View file @
80c9a609
...
@@ -293,7 +293,7 @@ flowList uId cId _ngs = do
...
@@ -293,7 +293,7 @@ flowList uId cId _ngs = do
pure
lId
pure
lId
flowListUser
::
RepoCmdM
env
err
m
flowListUser
::
RepoCmdM
env
err
m
=>
UserId
->
CorpusId
->
Int
->
m
Node
Id
=>
UserId
->
CorpusId
->
Int
->
m
List
Id
flowListUser
uId
cId
n
=
do
flowListUser
uId
cId
n
=
do
lId
<-
getOrMkList
cId
uId
lId
<-
getOrMkList
cId
uId
-- is <- insertLists lId $ ngrams2list ngs
-- is <- insertLists lId $ ngrams2list ngs
...
...
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