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
159
Issues
159
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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
868c8208
Commit
868c8208
authored
Dec 12, 2024
by
Grégoire Locqueville
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed some unused API code
parent
03d2b0e3
Pipeline
#7121
passed with stages
in 41 minutes and 25 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
93 deletions
+4
-93
New.hs
src/Gargantext/API/Node/Corpus/New.hs
+3
-68
Routes.hs
src/Gargantext/API/Routes.hs
+1
-25
No files found.
src/Gargantext/API/Node/Corpus/New.hs
View file @
868c8208
...
@@ -35,7 +35,7 @@ import Gargantext.API.Node.Corpus.Searx ( triggerSearxSearch )
...
@@ -35,7 +35,7 @@ import Gargantext.API.Node.Corpus.Searx ( triggerSearxSearch )
import
Gargantext.API.Node.Corpus.Types
(
Datafield
(
Web
),
database2origin
)
import
Gargantext.API.Node.Corpus.Types
(
Datafield
(
Web
),
database2origin
)
import
Gargantext.API.Node.Corpus.Update
(
addLanguageToCorpus
)
import
Gargantext.API.Node.Corpus.Update
(
addLanguageToCorpus
)
import
Gargantext.API.Node.Types
import
Gargantext.API.Node.Types
import
Gargantext.Core
(
withDefaultLanguage
,
defaultLanguage
)
import
Gargantext.Core
(
defaultLanguage
)
import
Gargantext.Core.Config
(
gc_jobs
,
hasConfig
)
import
Gargantext.Core.Config
(
gc_jobs
,
hasConfig
)
import
Gargantext.Core.Config.Types
(
jc_max_docs_parsers
)
import
Gargantext.Core.Config.Types
(
jc_max_docs_parsers
)
import
Gargantext.Core.NodeStory
(
HasNodeStoryImmediateSaver
,
HasNodeArchiveStoryImmediateSaver
,
currentVersion
,
NgramsStatePatch
'
)
import
Gargantext.Core.NodeStory
(
HasNodeStoryImmediateSaver
,
HasNodeArchiveStoryImmediateSaver
,
currentVersion
,
NgramsStatePatch
'
)
...
@@ -46,16 +46,11 @@ import Gargantext.Core.Utils.Prefix (unPrefix)
...
@@ -46,16 +46,11 @@ import Gargantext.Core.Utils.Prefix (unPrefix)
import
Gargantext.Database.Action.Flow
(
flowCorpus
,
getDataText
,
flowDataText
,
TermType
(
..
)
{-, allDataOrigins-}
)
import
Gargantext.Database.Action.Flow
(
flowCorpus
,
getDataText
,
flowDataText
,
TermType
(
..
)
{-, allDataOrigins-}
)
import
Gargantext.Database.Action.Flow.Types
(
FlowCmdM
)
import
Gargantext.Database.Action.Flow.Types
(
FlowCmdM
)
import
Gargantext.Database.Action.Mail
(
sendMail
)
import
Gargantext.Database.Action.Mail
(
sendMail
)
import
Gargantext.Database.Action.Node
(
mkNodeWithParent
)
import
Gargantext.Database.Action.User
(
getUserId
)
import
Gargantext.Database.Action.User
(
getUserId
)
import
Gargantext.Database.Admin.Types.Hyperdata.Document
(
ToHyperdataDocument
(
..
)
)
import
Gargantext.Database.Admin.Types.Hyperdata.Document
(
ToHyperdataDocument
(
..
)
)
import
Gargantext.Database.Admin.Types.Hyperdata.File
(
HyperdataFile
(
..
)
)
import
Gargantext.Database.Admin.Types.Node
(
CorpusId
,
ParentId
)
import
Gargantext.Database.Admin.Types.Node
(
CorpusId
,
NodeType
(
..
),
ParentId
)
import
Gargantext.Database.Query.Table.Node
(
getOrMkList
)
import
Gargantext.Database.GargDB
qualified
as
GargDB
import
Gargantext.Database.Query.Table.Node
(
getNodeWith
,
getOrMkList
)
import
Gargantext.Database.Query.Table.Node.UpdateOpaleye
(
updateHyperdata
)
import
Gargantext.Database.Query.Tree.Root
(
MkCorpusUser
(
MkCorpusUserNormalCorpusIds
))
import
Gargantext.Database.Query.Tree.Root
(
MkCorpusUser
(
MkCorpusUserNormalCorpusIds
))
import
Gargantext.Database.Schema.Node
(
node_hyperdata
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.System.Logging
(
logLocM
,
LogLevel
(
..
)
)
import
Gargantext.System.Logging
(
logLocM
,
LogLevel
(
..
)
)
import
Gargantext.Utils.Jobs.Monad
(
JobHandle
,
MonadJobStatus
(
..
))
import
Gargantext.Utils.Jobs.Monad
(
JobHandle
,
MonadJobStatus
(
..
))
...
@@ -234,66 +229,6 @@ addToCorpusWithForm user cid nwf jobHandle = do
...
@@ -234,66 +229,6 @@ addToCorpusWithForm user cid nwf jobHandle = do
$
(
logLocM
)
ERROR
$
"[addToCorpusWithForm] parse error: "
<>
(
Parser
.
_ParseFormatError
parseErr
)
$
(
logLocM
)
ERROR
$
"[addToCorpusWithForm] parse error: "
<>
(
Parser
.
_ParseFormatError
parseErr
)
markFailed
(
Just
parseErr
)
jobHandle
markFailed
(
Just
parseErr
)
jobHandle
{-
addToCorpusWithFile :: FlowCmdM env err m
=> CorpusId
-> MultipartData Mem
-> Maybe FileType
-> (JobLog -> m ())
-> m JobLog
addToCorpusWithFile cid input filetype logStatus = do
logStatus JobLog { _scst_succeeded = Just 10
, _scst_failed = Just 2
, _scst_remaining = Just 138
, _scst_events = Just []
}
printDebug "addToCorpusWithFile" cid
_h <- postUpload cid filetype input
pure JobLog { _scst_succeeded = Just 137
, _scst_failed = Just 13
, _scst_remaining = Just 0
, _scst_events = Just []
}
-}
addToCorpusWithFile
::
(
FlowCmdM
env
err
m
,
MonadJobStatus
m
)
=>
User
->
CorpusId
->
NewWithFile
->
JobHandle
m
->
m
()
addToCorpusWithFile
user
cid
nwf
@
(
NewWithFile
_d
(
withDefaultLanguage
->
l
)
fName
)
jobHandle
=
do
addLanguageToCorpus
cid
l
$
(
logLocM
)
DEBUG
$
"[addToCorpusWithFile] Uploading file to corpus: "
<>
show
cid
markStarted
1
jobHandle
fPath
<-
GargDB
.
writeFile
nwf
$
(
logLocM
)
DEBUG
$
"[addToCorpusWithFile] File saved as: "
<>
show
fPath
uId
<-
getUserId
user
nIds
<-
mkNodeWithParent
NodeFile
(
Just
cid
)
uId
fName
_
<-
case
nIds
of
[
nId
]
->
do
node
<-
getNodeWith
nId
(
Proxy
::
Proxy
HyperdataFile
)
let
hl
=
node
^.
node_hyperdata
_
<-
updateHyperdata
nId
$
hl
{
_hff_name
=
fName
,
_hff_path
=
T
.
pack
fPath
}
$
(
logLocM
)
DEBUG
$
"[addToCorpusWithFile] Created node with id: "
<>
show
nId
_
->
pure
()
$
(
logLocM
)
DEBUG
$
"[addToCorpusWithFile] File upload to corpus finished: "
<>
show
cid
$
(
logLocM
)
DEBUG
$
"[addToCorpusWithFile] sending email: "
<>
(
"xxxxxxxxxxxxxxxxxxxxx"
::
Text
)
sendMail
user
markComplete
jobHandle
--- UTILITIES
--- UTILITIES
...
...
src/Gargantext/API/Routes.hs
View file @
868c8208
...
@@ -19,41 +19,17 @@ module Gargantext.API.Routes
...
@@ -19,41 +19,17 @@ module Gargantext.API.Routes
import
Gargantext.API.Admin.EnvTypes
(
Env
)
import
Gargantext.API.Admin.EnvTypes
(
Env
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Prelude
(
Garg
Server
,
Garg
M
)
import
Gargantext.API.Prelude
(
GargM
)
import
Gargantext.API.Routes.Named.Annuaire
qualified
as
Named
import
Gargantext.API.Routes.Named.Annuaire
qualified
as
Named
import
Gargantext.API.Routes.Named.Corpus
qualified
as
Named
import
Gargantext.API.Routes.Named.Corpus
qualified
as
Named
import
Gargantext.API.Worker
(
serveWorkerAPI
)
import
Gargantext.API.Worker
(
serveWorkerAPI
)
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Core.Worker.Jobs.Types
qualified
as
Jobs
import
Gargantext.Core.Worker.Jobs.Types
qualified
as
Jobs
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Servant
(
Get
,
JSON
)
import
Servant.Server.Generic
(
AsServerT
)
import
Servant.Server.Generic
(
AsServerT
)
----------------------------------------------------------------------
-- For Tests
type
WaitAPI
=
Get
'[
J
SON
]
Text
waitAPI
::
Int
->
GargServer
WaitAPI
waitAPI
n
=
do
let
m
=
(
10
::
Int
)
^
(
6
::
Int
)
_
<-
liftBase
$
threadDelay
(
m
*
n
)
pure
$
"Waited: "
<>
show
n
----------------------------------------
----------------------------------------
-- addCorpusWithQuery :: User -> Named.AddWithQuery (AsServerT (GargM Env BackendInternalError))
-- addCorpusWithQuery user = Named.AddWithQuery $ \cid -> AsyncJobs $
-- serveJobsAPI AddCorpusQueryJob $ \_jHandle q -> do
-- -- limit <- view $ hasConfig . gc_jobs . jc_max_docs_scrapers
-- -- New.addToCorpusWithQuery user cid q (Just $ fromIntegral limit) jHandle
-- void $ Jobs.sendJob $ Jobs.AddCorpusWithQuery { Jobs._acq_args = q
-- , Jobs._acq_user = user
-- , Jobs._acq_cid = cid }
{- let log' x = do
printDebug "addToCorpusWithQuery" x
liftBase $ log x
addCorpusWithQuery
::
User
->
Named
.
AddWithQuery
(
AsServerT
(
GargM
Env
BackendInternalError
))
addCorpusWithQuery
::
User
->
Named
.
AddWithQuery
(
AsServerT
(
GargM
Env
BackendInternalError
))
addCorpusWithQuery
user
=
addCorpusWithQuery
user
=
Named
.
AddWithQuery
{
Named
.
AddWithQuery
{
...
...
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