Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
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
Przemyslaw Kaminski
haskell-gargantext
Commits
5850ff95
Commit
5850ff95
authored
Apr 06, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ASYNC] for tests
parent
48a8c59d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
28 deletions
+24
-28
New.hs
src/Gargantext/API/Corpus/New.hs
+24
-28
No files found.
src/Gargantext/API/Corpus/New.hs
View file @
5850ff95
...
...
@@ -28,7 +28,6 @@ module Gargantext.API.Corpus.New
--import Gargantext.Text.Corpus.Parsers (parseFile, FileFormat(..))
import
Control.Lens
hiding
(
elements
)
import
Control.Monad.IO.Class
(
liftIO
)
import
Control.Concurrent
import
Data.Aeson
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Maybe
(
fromMaybe
)
...
...
@@ -245,23 +244,8 @@ addToCorpusWithForm :: FlowCmdM env err m
->
WithForm
->
(
ScraperStatus
->
m
()
)
->
m
ScraperStatus
addToCorpusWithForm
cid
(
WithForm
ft
d
l
_n
)
logStatus
=
do
addToCorpusWithForm
cid
form
logStatus
=
do
printDebug
"ft"
ft
let
parse
=
case
ft
of
CSV_HAL
->
Parser
.
parseFormat
Parser
.
CsvHal
CSV
->
Parser
.
parseFormat
Parser
.
CsvGargV3
WOS
->
Parser
.
parseFormat
Parser
.
WOS
PresseRIS
->
Parser
.
parseFormat
Parser
.
RisPresse
newDocs
<-
liftIO
newEmptyMVar
_
<-
liftIO
$
forkIO
<$>
putMVar
newDocs
<$>
splitEvery
500
<$>
take
1000000
<$>
parse
(
cs
d
)
logStatus
ScraperStatus
{
_scst_succeeded
=
Just
1
,
_scst_failed
=
Just
0
...
...
@@ -269,17 +253,7 @@ addToCorpusWithForm cid (WithForm ft d l _n) logStatus = do
,
_scst_events
=
Just
[]
}
docs'
<-
liftIO
$
takeMVar
newDocs
newCid
<-
liftIO
newEmptyMVar
_
<-
forkIO
<$>
putMVar
newCid
<$>
flowCorpus
"user1"
(
Right
[
cid
])
(
Multi
$
fromMaybe
EN
l
)
(
map
(
map
toHyperdataDocument
)
docs'
)
cid''
<-
liftIO
$
takeMVar
newCid
printDebug
"cid'"
cid''
_
<-
asyncFlowCorpus
cid
form
pure
ScraperStatus
{
_scst_succeeded
=
Just
2
,
_scst_failed
=
Just
0
...
...
@@ -287,3 +261,25 @@ addToCorpusWithForm cid (WithForm ft d l _n) logStatus = do
,
_scst_events
=
Just
[]
}
asyncFlowCorpus
::
FlowCmdM
env
err
m
=>
CorpusId
->
WithForm
->
m
()
asyncFlowCorpus
cid
(
WithForm
ft
d
l
_n
)
=
do
let
parse
=
case
ft
of
CSV_HAL
->
Parser
.
parseFormat
Parser
.
CsvHal
CSV
->
Parser
.
parseFormat
Parser
.
CsvGargV3
WOS
->
Parser
.
parseFormat
Parser
.
WOS
PresseRIS
->
Parser
.
parseFormat
Parser
.
RisPresse
docs
<-
liftIO
$
splitEvery
500
<$>
take
1000000
<$>
parse
(
cs
d
)
_cid'
<-
flowCorpus
"user1"
(
Right
[
cid
])
(
Multi
$
fromMaybe
EN
l
)
(
map
(
map
toHyperdataDocument
)
docs
)
pure
()
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