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
ec4c006c
Commit
ec4c006c
authored
Nov 02, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ngrams] logRef for logging task progress
NOTE: for some reason this doesn't compile yet
parent
cca441fb
Pipeline
#1183
failed with stage
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
33 deletions
+50
-33
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+31
-30
Routes.hs
src/Gargantext/API/Routes.hs
+1
-1
Job.hs
src/Gargantext/Prelude/Job.hs
+18
-2
No files found.
src/Gargantext/API/Ngrams.hs
View file @
ec4c006c
{-# OPTIONS_GHC -fno-warn-unused-top-binds
-fno-warn-name-shadowing
#-}
{-# OPTIONS_GHC -fno-warn-unused-top-binds #-}
{-|
{-|
Module : Gargantext.API.Ngrams
Module : Gargantext.API.Ngrams
Description : Server API
Description : Server API
...
@@ -375,52 +375,53 @@ tableNgramsPostChartsAsync utn logStatus = do
...
@@ -375,52 +375,53 @@ tableNgramsPostChartsAsync utn logStatus = do
case
tabType
of
case
tabType
of
Authors
->
do
Authors
->
do
-- printDebug "[tableNgramsPut] Authors, updating Pie, cId" cId
-- printDebug "[tableNgramsPut] Authors, updating Pie, cId" cId
let
jl
=
jobLogInit
1
(
logRef
,
logRefSuccess
,
getRef
)
<-
runJobLog
1
logStatus
log
Status
jl
log
Ref
_
<-
Metrics
.
updatePie
cId
(
Just
listId
)
tabType
Nothing
_
<-
Metrics
.
updatePie
cId
(
Just
listId
)
tabType
Nothing
pure
$
jobLogSuccess
jl
logRefSuccess
getRef
Institutes
->
do
Institutes
->
do
-- printDebug "[tableNgramsPut] Institutes, updating Tree, cId" cId
-- printDebug "[tableNgramsPut] Institutes, updating Tree, cId" cId
-- printDebug "[tableNgramsPut] updating tree StopTerm, cId" cId
-- printDebug "[tableNgramsPut] updating tree StopTerm, cId" cId
let
jl
=
jobLogInit
3
(
logRef
,
logRefSuccess
,
getRef
)
<-
runJobLog
3
logStatus
log
Status
jl
log
Ref
_
<-
Metrics
.
updateTree
cId
(
Just
listId
)
tabType
StopTerm
_
<-
Metrics
.
updateTree
cId
(
Just
listId
)
tabType
StopTerm
-- printDebug "[tableNgramsPut] updating tree CandidateTerm, cId" cId
-- printDebug "[tableNgramsPut] updating tree CandidateTerm, cId" cId
let
jl
=
jobLogSuccess
jl
logRefSuccess
logStatus
jl
_
<-
Metrics
.
updateTree
cId
(
Just
listId
)
tabType
CandidateTerm
_
<-
Metrics
.
updateTree
cId
(
Just
listId
)
tabType
CandidateTerm
-- printDebug "[tableNgramsPut] updating tree MapTerm, cId" cId
-- printDebug "[tableNgramsPut] updating tree MapTerm, cId" cId
let
jl
=
jobLogSuccess
jl
logRefSuccess
logStatus
jl
_
<-
Metrics
.
updateTree
cId
(
Just
listId
)
tabType
MapTerm
_
<-
Metrics
.
updateTree
cId
(
Just
listId
)
tabType
MapTerm
pure
$
jobLogSuccess
jl
logRefSuccess
getRef
Sources
->
do
Sources
->
do
-- printDebug "[tableNgramsPut] Sources, updating chart, cId" cId
-- printDebug "[tableNgramsPut] Sources, updating chart, cId" cId
let
jl
=
jobLogInit
1
(
logRef
,
logRefSuccess
,
getRef
)
<-
runJobLog
1
logStatus
log
Status
jl
log
Ref
_
<-
Metrics
.
updatePie
cId
(
Just
listId
)
tabType
Nothing
_
<-
Metrics
.
updatePie
cId
(
Just
listId
)
tabType
Nothing
pure
$
jobLogSuccess
jl
logRefSuccess
getRef
Terms
->
do
Terms
->
do
-- printDebug "[tableNgramsPut] Terms, updating Metrics (Histo), cId" cId
-- printDebug "[tableNgramsPut] Terms, updating Metrics (Histo), cId" cId
let
jl
=
jobLogInit
6
(
logRef
,
logRefSuccess
,
getRef
)
<-
runJobLog
6
logStatus
log
Status
jl
log
Ref
_
<-
Metrics
.
updateChart
cId
(
Just
listId
)
tabType
Nothing
_
<-
Metrics
.
updateChart
cId
(
Just
listId
)
tabType
Nothing
let
jl
=
jobLogSuccess
jl
logRefSuccess
logStatus
jl
_
<-
Metrics
.
updatePie
cId
(
Just
listId
)
tabType
Nothing
_
<-
Metrics
.
updatePie
cId
(
Just
listId
)
tabType
Nothing
let
jl
=
jobLogSuccess
jl
logRefSuccess
logStatus
jl
_
<-
Metrics
.
updateScatter
cId
(
Just
listId
)
tabType
Nothing
_
<-
Metrics
.
updateScatter
cId
(
Just
listId
)
tabType
Nothing
let
jl
=
jobLogSuccess
jl
logRefSuccess
logStatus
jl
_
<-
Metrics
.
updateTree
cId
(
Just
listId
)
tabType
StopTerm
_
<-
Metrics
.
updateTree
cId
(
Just
listId
)
tabType
StopTerm
let
jl
=
jobLogSuccess
jl
logRefSuccess
logStatus
jl
_
<-
Metrics
.
updateTree
cId
(
Just
listId
)
tabType
CandidateTerm
_
<-
Metrics
.
updateTree
cId
(
Just
listId
)
tabType
CandidateTerm
let
jl
=
jobLogSuccess
jl
logRefSuccess
logStatus
jl
_
<-
Metrics
.
updateTree
cId
(
Just
listId
)
tabType
MapTerm
_
<-
Metrics
.
updateTree
cId
(
Just
listId
)
tabType
MapTerm
pure
$
jobLogSuccess
jl
logRefSuccess
getRef
_
->
do
_
->
do
printDebug
"[tableNgramsPut] no update for tabType = "
tabType
printDebug
"[tableNgramsPut] no update for tabType = "
tabType
pure
$
jobLogFail
$
jobLogInit
1
pure
$
jobLogFail
$
jobLogInit
1
...
@@ -729,12 +730,12 @@ apiNgramsTableDoc dId = getTableNgramsDoc dId
...
@@ -729,12 +730,12 @@ apiNgramsTableDoc dId = getTableNgramsDoc dId
apiNgramsAsync
::
NodeId
->
GargServer
TableNgramsAsyncApi
apiNgramsAsync
::
NodeId
->
GargServer
TableNgramsAsyncApi
apiNgramsAsync
_dId
=
apiNgramsAsync
_dId
=
serveJobsAPI
$
serveJobsAPI
$
JobFunction
(
\
i
l
->
JobFunction
$
\
i
log
->
let
let
log'
x
=
do
log'
x
=
do
printDebug
"tableNgramsPostChartsAsync"
x
printDebug
"tableNgramsPostChartsAsync"
x
liftBase
$
l
x
liftBase
$
l
og
x
in
tableNgramsPostChartsAsync
i
log'
)
in
tableNgramsPostChartsAsync
i
log'
-- Did the given list of ngrams changed since the given version?
-- Did the given list of ngrams changed since the given version?
-- The returned value is versioned boolean value, meaning that one always retrieve the
-- The returned value is versioned boolean value, meaning that one always retrieve the
...
...
src/Gargantext/API/Routes.hs
View file @
ec4c006c
...
@@ -251,7 +251,7 @@ addCorpusWithQuery user cid =
...
@@ -251,7 +251,7 @@ addCorpusWithQuery user cid =
serveJobsAPI
$
serveJobsAPI
$
JobFunction
(
\
q
log
->
do
JobFunction
(
\
q
log
->
do
limit
<-
view
$
config
.
gc_max_docs_scrapers
limit
<-
view
$
config
.
gc_max_docs_scrapers
New
.
addToCorpusWithQuery
user
cid
q
(
Just
limit
)
(
liftBase
.
log
)
New
.
a
https
://
filezilla
-
project
.
org
/
ddToCorpusWithQuery
user
cid
q
(
Just
limit
)
(
liftBase
.
log
)
{- let log' x = do
{- let log' x = do
printDebug "addToCorpusWithQuery" x
printDebug "addToCorpusWithQuery" x
liftBase $ log x
liftBase $ log x
...
...
src/Gargantext/Prelude/Job.hs
View file @
ec4c006c
module
Gargantext.Prelude.Job
where
module
Gargantext.Prelude.Job
where
import
Data.IORef
import
Data.Maybe
import
Data.Maybe
import
Gargantext.Prelude
import
Gargantext.Prelude
...
@@ -19,7 +20,7 @@ jobLogSuccess (JobLog { _scst_succeeded = mSucc
...
@@ -19,7 +20,7 @@ jobLogSuccess (JobLog { _scst_succeeded = mSucc
,
_scst_failed
=
mFail
,
_scst_failed
=
mFail
,
_scst_events
=
evt
})
=
,
_scst_events
=
evt
})
=
JobLog
{
_scst_succeeded
=
(
+
1
)
<$>
mSucc
JobLog
{
_scst_succeeded
=
(
+
1
)
<$>
mSucc
,
_scst_remaining
=
(
+
1
)
<$>
mRem
,
_scst_remaining
=
(
\
x
->
x
-
1
)
<$>
mRem
,
_scst_failed
=
mFail
,
_scst_failed
=
mFail
,
_scst_events
=
evt
}
,
_scst_events
=
evt
}
...
@@ -29,7 +30,22 @@ jobLogFail (JobLog { _scst_succeeded = mSucc
...
@@ -29,7 +30,22 @@ jobLogFail (JobLog { _scst_succeeded = mSucc
,
_scst_remaining
=
mRem
,
_scst_remaining
=
mRem
,
_scst_failed
=
mFail
,
_scst_failed
=
mFail
,
_scst_events
=
evt
})
=
,
_scst_events
=
evt
})
=
JobLog
{
_scst_succeeded
=
(
+
1
)
<$>
mSucc
JobLog
{
_scst_succeeded
=
mSucc
,
_scst_remaining
=
(
\
x
->
x
-
1
)
<$>
mRem
,
_scst_remaining
=
(
\
x
->
x
-
1
)
<$>
mRem
,
_scst_failed
=
(
+
1
)
<$>
mFail
,
_scst_failed
=
(
+
1
)
<$>
mFail
,
_scst_events
=
evt
}
,
_scst_events
=
evt
}
runJobLog
::
Int
->
(
JobLog
->
IO
()
)
->
IO
(
IO
()
,
IO
()
,
IO
JobLog
)
runJobLog
num
logStatus
=
do
jlRef
<-
newIORef
$
jobLogInit
num
let
logRef
=
do
jl
<-
readIORef
jlRef
logStatus
jl
let
logRefSuccess
=
do
jl
<-
readIORef
jlRef
writeIORef
$
jobLogSuccess
jl
let
getRef
=
do
readIORef
jlRef
return
(
logRef
,
logRefSuccess
,
getRef
)
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