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
148
Issues
148
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
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
28e2927e
Commit
28e2927e
authored
Dec 02, 2024
by
Grégoire Locqueville
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deal with error with a proper error
... instead of returning a `Maybe` to the frontend
parent
54675ae8
Pipeline
#7097
passed with stages
in 59 minutes and 20 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
8 deletions
+10
-8
Subcorpus.hs
src/Gargantext/API/Node/Corpus/Subcorpus.hs
+8
-6
Corpus.hs
src/Gargantext/API/Routes/Named/Corpus.hs
+2
-2
No files found.
src/Gargantext/API/Node/Corpus/Subcorpus.hs
View file @
28e2927e
module
Gargantext.API.Node.Corpus.Subcorpus
where
import
Data.Validity
(
Validation
(
..
),
ValidationChain
(
..
))
import
Gargantext.Prelude
import
Gargantext.API.Errors.Types
(
BackendInternalError
)
import
Gargantext.API.Errors.Types
(
BackendInternalError
(
..
))
import
Gargantext.API.Routes.Named.Corpus
(
MakeSubcorpusAPI
(
..
),
SubcorpusParams
(
..
))
import
Gargantext.Core.NodeStory.Types
(
HasNodeStoryEnv
)
import
Gargantext.Core.NLP
(
HasNLPServer
)
...
...
@@ -21,12 +21,14 @@ makeSubcorpus :: ( HasNodeStoryEnv env
=>
UserId
->
MakeSubcorpusAPI
(
AsServerT
m
)
makeSubcorpus
user
=
MakeSubcorpusAPI
$
\
corpusId
params
->
do
case
parseQuery
(
RawQuery
$
_subcorpusParams_query
params
)
of
Left
_
->
return
Nothing
Right
q
->
do
let
queryText
=
_subcorpusParams_query
params
case
parseQuery
(
RawQuery
queryText
)
of
Left
msg
->
throwError
$
InternalValidationError
$
Validation
[
Violated
$
"Failed to parse the query "
<>
show
queryText
<>
": "
<>
msg
]
Right
q
->
do
subcorpusId
<-
makeSubcorpusFromQuery
(
UserDBId
user
)
corpusId
q
(
_subcorpusParams_reuseParentList
params
)
return
$
Just
subcorpusId
return
subcorpusId
src/Gargantext/API/Routes/Named/Corpus.hs
View file @
28e2927e
...
...
@@ -31,7 +31,7 @@ import Gargantext.API.Worker (WorkerAPI)
import
Gargantext.Core.Text.Ngrams
(
NgramsType
(
..
))
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
)
import
Gargantext.Database.Admin.Types.Node
(
CorpusId
,
ListId
,
NodeId
)
import
Gargantext.Prelude
(
Bool
,
Maybe
)
import
Gargantext.Prelude
(
Bool
)
import
Servant
--------------------------------------------------
...
...
@@ -67,7 +67,7 @@ newtype MakeSubcorpusAPI mode = MakeSubcorpusAPI
:>
Capture
"corpus_id"
CorpusId
:>
"subcorpus"
:>
ReqBody
'[
J
SON
]
SubcorpusParams
:>
Post
'[
J
SON
]
(
Maybe
NodeId
)
-- new subcorpus ID, if successful
:>
Post
'[
J
SON
]
NodeId
-- new subcorpus ID
}
deriving
Generic
data
SubcorpusParams
=
SubcorpusParams
...
...
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