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
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
Changes
3
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
Description : Server API
...
...
@@ -375,52 +375,53 @@ tableNgramsPostChartsAsync utn logStatus = do
case
tabType
of
Authors
->
do
-- printDebug "[tableNgramsPut] Authors, updating Pie, cId" cId
let
jl
=
jobLogInit
1
log
Status
jl
(
logRef
,
logRefSuccess
,
getRef
)
<-
runJobLog
1
logStatus
log
Ref
_
<-
Metrics
.
updatePie
cId
(
Just
listId
)
tabType
Nothing
pure
$
jobLogSuccess
jl
logRefSuccess
getRef
Institutes
->
do
-- printDebug "[tableNgramsPut] Institutes, updating Tree, cId" cId
-- printDebug "[tableNgramsPut] updating tree StopTerm, cId" cId
let
jl
=
jobLogInit
3
log
Status
jl
(
logRef
,
logRefSuccess
,
getRef
)
<-
runJobLog
3
logStatus
log
Ref
_
<-
Metrics
.
updateTree
cId
(
Just
listId
)
tabType
StopTerm
-- printDebug "[tableNgramsPut] updating tree CandidateTerm, cId" cId
let
jl
=
jobLogSuccess
jl
logStatus
jl
logRefSuccess
_
<-
Metrics
.
updateTree
cId
(
Just
listId
)
tabType
CandidateTerm
-- printDebug "[tableNgramsPut] updating tree MapTerm, cId" cId
let
jl
=
jobLogSuccess
jl
logStatus
jl
logRefSuccess
_
<-
Metrics
.
updateTree
cId
(
Just
listId
)
tabType
MapTerm
pure
$
jobLogSuccess
jl
logRefSuccess
getRef
Sources
->
do
-- printDebug "[tableNgramsPut] Sources, updating chart, cId" cId
let
jl
=
jobLogInit
1
log
Status
jl
(
logRef
,
logRefSuccess
,
getRef
)
<-
runJobLog
1
logStatus
log
Ref
_
<-
Metrics
.
updatePie
cId
(
Just
listId
)
tabType
Nothing
pure
$
jobLogSuccess
jl
logRefSuccess
getRef
Terms
->
do
-- printDebug "[tableNgramsPut] Terms, updating Metrics (Histo), cId" cId
let
jl
=
jobLogInit
6
log
Status
jl
(
logRef
,
logRefSuccess
,
getRef
)
<-
runJobLog
6
logStatus
log
Ref
_
<-
Metrics
.
updateChart
cId
(
Just
listId
)
tabType
Nothing
let
jl
=
jobLogSuccess
jl
logStatus
jl
logRefSuccess
_
<-
Metrics
.
updatePie
cId
(
Just
listId
)
tabType
Nothing
let
jl
=
jobLogSuccess
jl
logStatus
jl
logRefSuccess
_
<-
Metrics
.
updateScatter
cId
(
Just
listId
)
tabType
Nothing
let
jl
=
jobLogSuccess
jl
logStatus
jl
logRefSuccess
_
<-
Metrics
.
updateTree
cId
(
Just
listId
)
tabType
StopTerm
let
jl
=
jobLogSuccess
jl
logStatus
jl
logRefSuccess
_
<-
Metrics
.
updateTree
cId
(
Just
listId
)
tabType
CandidateTerm
let
jl
=
jobLogSuccess
jl
logStatus
jl
logRefSuccess
_
<-
Metrics
.
updateTree
cId
(
Just
listId
)
tabType
MapTerm
pure
$
jobLogSuccess
jl
logRefSuccess
getRef
_
->
do
printDebug
"[tableNgramsPut] no update for tabType = "
tabType
pure
$
jobLogFail
$
jobLogInit
1
...
...
@@ -729,12 +730,12 @@ apiNgramsTableDoc dId = getTableNgramsDoc dId
apiNgramsAsync
::
NodeId
->
GargServer
TableNgramsAsyncApi
apiNgramsAsync
_dId
=
serveJobsAPI
$
JobFunction
(
\
i
l
->
JobFunction
$
\
i
log
->
let
log'
x
=
do
printDebug
"tableNgramsPostChartsAsync"
x
liftBase
$
l
x
in
tableNgramsPostChartsAsync
i
log'
)
liftBase
$
l
og
x
in
tableNgramsPostChartsAsync
i
log'
-- Did the given list of ngrams changed since the given version?
-- 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 =
serveJobsAPI
$
JobFunction
(
\
q
log
->
do
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
printDebug "addToCorpusWithQuery" x
liftBase $ log x
...
...
src/Gargantext/Prelude/Job.hs
View file @
ec4c006c
module
Gargantext.Prelude.Job
where
import
Data.IORef
import
Data.Maybe
import
Gargantext.Prelude
...
...
@@ -19,7 +20,7 @@ jobLogSuccess (JobLog { _scst_succeeded = mSucc
,
_scst_failed
=
mFail
,
_scst_events
=
evt
})
=
JobLog
{
_scst_succeeded
=
(
+
1
)
<$>
mSucc
,
_scst_remaining
=
(
+
1
)
<$>
mRem
,
_scst_remaining
=
(
\
x
->
x
-
1
)
<$>
mRem
,
_scst_failed
=
mFail
,
_scst_events
=
evt
}
...
...
@@ -29,7 +30,22 @@ jobLogFail (JobLog { _scst_succeeded = mSucc
,
_scst_remaining
=
mRem
,
_scst_failed
=
mFail
,
_scst_events
=
evt
})
=
JobLog
{
_scst_succeeded
=
(
+
1
)
<$>
mSucc
JobLog
{
_scst_succeeded
=
mSucc
,
_scst_remaining
=
(
\
x
->
x
-
1
)
<$>
mRem
,
_scst_failed
=
(
+
1
)
<$>
mFail
,
_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