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
8a9b8c9b
Unverified
Commit
8a9b8c9b
authored
Feb 04, 2019
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NGRAMS-REPO] Mock repo in dev-mode
parent
3a4ebb3e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
18 deletions
+28
-18
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+26
-16
Settings.hs
src/Gargantext/API/Settings.hs
+2
-2
No files found.
src/Gargantext/API/Ngrams.hs
View file @
8a9b8c9b
...
...
@@ -176,23 +176,25 @@ toNgramsElement ns = map toNgramsElement' ns
$ map (\(NgramsTableData _ p t _ _ _) -> (p, Set.singleton t)) ns
-}
mockTable
::
NgramsTable
mockTable
=
NgramsTable
[
NgramsElement
"animal"
GraphList
1
Nothing
(
mSetFromList
[
"dog"
,
"cat"
])
,
NgramsElement
"cat"
GraphList
1
(
Just
"animal"
)
mempty
,
NgramsElement
"cats"
StopList
4
Nothing
mempty
,
NgramsElement
"dog"
GraphList
3
(
Just
"animal"
)(
mSetFromList
[
"dogs"
])
,
NgramsElement
"dogs"
StopList
4
(
Just
"dog"
)
mempty
,
NgramsElement
"fox"
GraphList
1
Nothing
mempty
,
NgramsElement
"object"
CandidateList
2
Nothing
mempty
,
NgramsElement
"nothing"
StopList
4
Nothing
mempty
,
NgramsElement
"organic"
GraphList
3
Nothing
(
mSetFromList
[
"flower"
])
,
NgramsElement
"flower"
GraphList
3
(
Just
"organic"
)
mempty
,
NgramsElement
"moon"
CandidateList
1
Nothing
mempty
,
NgramsElement
"sky"
StopList
1
Nothing
mempty
]
instance
Arbitrary
NgramsTable
where
arbitrary
=
elements
[
NgramsTable
[
NgramsElement
"animal"
GraphList
1
Nothing
(
mSetFromList
[
"dog"
,
"cat"
])
,
NgramsElement
"cat"
GraphList
1
(
Just
"animal"
)
mempty
,
NgramsElement
"cats"
StopList
4
Nothing
mempty
,
NgramsElement
"dog"
GraphList
3
(
Just
"animal"
)(
mSetFromList
[
"dogs"
])
,
NgramsElement
"dogs"
StopList
4
(
Just
"dog"
)
mempty
,
NgramsElement
"fox"
GraphList
1
Nothing
mempty
,
NgramsElement
"object"
CandidateList
2
Nothing
mempty
,
NgramsElement
"nothing"
StopList
4
Nothing
mempty
,
NgramsElement
"organic"
GraphList
3
Nothing
(
mSetFromList
[
"flower"
])
,
NgramsElement
"flower"
GraphList
3
(
Just
"organic"
)
mempty
,
NgramsElement
"moon"
CandidateList
1
Nothing
mempty
,
NgramsElement
"sky"
StopList
1
Nothing
mempty
]
]
arbitrary
=
pure
mockTable
instance
ToSchema
NgramsTable
------------------------------------------------------------------------
...
...
@@ -547,6 +549,14 @@ type NgramsState = Map ListId (Map NgramsType NgramsTableMap)
type
NgramsStatePatch
=
PatchMap
ListId
(
PatchMap
NgramsType
NgramsTablePatch
)
type
NgramsRepo
=
Repo
NgramsState
NgramsStatePatch
initMockRepo
::
NgramsRepo
initMockRepo
=
Repo
1
s
[]
where
s
=
Map
.
singleton
1
$
Map
.
singleton
Ngrams
.
NgramsTerms
$
Map
.
fromList
[
(
n
^.
ne_ngrams
,
n
)
|
n
<-
mockTable
^.
_NgramsTable
]
class
HasRepoVar
env
where
repoVar
::
Getter
env
(
MVar
NgramsRepo
)
...
...
src/Gargantext/API/Settings.hs
View file @
8a9b8c9b
...
...
@@ -50,7 +50,7 @@ import Control.Monad.Logger
import
Control.Lens
import
Gargantext.Prelude
import
Gargantext.Database.Utils
(
databaseParameters
,
HasConnection
(
..
))
import
Gargantext.API.Ngrams
(
NgramsRepo
,
HasRepoVar
(
..
),
initRepo
)
import
Gargantext.API.Ngrams
(
NgramsRepo
,
HasRepoVar
(
..
),
init
Mock
Repo
)
import
Gargantext.API.Orchestrator.Types
type
PortNumber
=
Int
...
...
@@ -161,7 +161,7 @@ newEnv port file = do
self_url
<-
parseBaseUrl
$
"http://0.0.0.0:"
<>
show
port
param
<-
databaseParameters
file
conn
<-
connect
param
repo_var
<-
newMVar
initRepo
repo_var
<-
newMVar
init
Mock
Repo
scrapers_env
<-
newJobEnv
defaultSettings
manager
logger
<-
newStderrLoggerSet
defaultBufSize
pure
$
Env
...
...
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