Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-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
Grégoire Locqueville
purescript-gargantext
Commits
cdae18ff
Commit
cdae18ff
authored
Dec 13, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ngrams] fixes to ngrams PUT JSON response
parent
5e12ef58
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
12 deletions
+26
-12
REST.purs
src/Gargantext/Config/REST.purs
+4
-3
Functions.purs
src/Gargantext/Core/NgramsTable/Functions.purs
+2
-2
Types.purs
src/Gargantext/Core/NgramsTable/Types.purs
+11
-6
SimpleJSON.purs
src/Gargantext/Utils/SimpleJSON.purs
+9
-1
No files found.
src/Gargantext/Config/REST.purs
View file @
cdae18ff
...
@@ -45,9 +45,10 @@ instance Eq RESTError where
...
@@ -45,9 +45,10 @@ instance Eq RESTError where
eq _ _ = false
eq _ _ = false
logRESTError :: R2.Here -> String -> RESTError -> Effect Unit
logRESTError :: R2.Here -> String -> RESTError -> Effect Unit
logRESTError here prefix (SendResponseError e) = here.warn2 (prefix <> " SendResponseError ") e -- TODO: No show
logRESTError here prefix e = here.warn2 (prefix <> " " <> show e) e
logRESTError here prefix (ReadJSONError e) = here.warn2 (prefix <> " ReadJSONError ") $ show e
-- logRESTError here prefix (SendResponseError e) = here.warn2 (prefix <> " SendResponseError ") e -- TODO: No show
logRESTError here prefix (CustomError e) = here.warn2 (prefix <> " CustomError ") $ e
-- logRESTError here prefix (ReadJSONError e) = here.warn2 (prefix <> " ReadJSONError ") $ show e
-- logRESTError here prefix (CustomError e) = here.warn2 (prefix <> " CustomError ") $ e
type AffRESTError a = Aff (Either RESTError a)
type AffRESTError a = Aff (Either RESTError a)
...
...
src/Gargantext/Core/NgramsTable/Functions.purs
View file @
cdae18ff
...
@@ -35,7 +35,7 @@ import Effect.Class (liftEffect)
...
@@ -35,7 +35,7 @@ import Effect.Class (liftEffect)
import Gargantext.AsyncTasks as GAT
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.Table as T
import Gargantext.Components.Table as T
import Gargantext.Components.Table.Types as T
import Gargantext.Components.Table.Types as T
import Gargantext.Config.REST (AffRESTError, RESTError)
import Gargantext.Config.REST (AffRESTError, RESTError
, logRESTError
)
import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Core.NgramsTable.Types
import Gargantext.Core.NgramsTable.Types
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Routes (SessionRoute(..))
...
@@ -375,7 +375,7 @@ syncPatches props state callback = do
...
@@ -375,7 +375,7 @@ syncPatches props state callback = do
launchAff_ $ do
launchAff_ $ do
ePatches <- putNgramsPatches props pt
ePatches <- putNgramsPatches props pt
case ePatches of
case ePatches of
Left err -> liftEffect $
here.warn2 "[syncPatches] RESTError
" err
Left err -> liftEffect $
logRESTError here "[syncPatches]
" err
Right (Versioned { data: newPatch, version: newVersion }) -> do
Right (Versioned { data: newPatch, version: newVersion }) -> do
callback unit
callback unit
liftEffect $ do
liftEffect $ do
...
...
src/Gargantext/Core/NgramsTable/Types.purs
View file @
cdae18ff
...
@@ -13,9 +13,10 @@ import Data.Lens.Index (class Index, ix)
...
@@ -13,9 +13,10 @@ import Data.Lens.Index (class Index, ix)
import Data.Lens.Iso.Newtype (_Newtype)
import Data.Lens.Iso.Newtype (_Newtype)
import Data.Lens.Record (prop)
import Data.Lens.Record (prop)
import Data.List (List)
import Data.List (List)
import Data.List.Types (NonEmptyList(..))
import Data.Map (Map)
import Data.Map (Map)
import Data.Map as Map
import Data.Map as Map
import Data.Maybe (Maybe(..), isJust)
import Data.Maybe (Maybe(..),
fromJust,
isJust)
import Data.Newtype (class Newtype)
import Data.Newtype (class Newtype)
import Data.Ord.Generic (genericCompare)
import Data.Ord.Generic (genericCompare)
import Data.Show.Generic (genericShow)
import Data.Show.Generic (genericShow)
...
@@ -32,6 +33,7 @@ import Gargantext.Components.Table.Types as T
...
@@ -32,6 +33,7 @@ import Gargantext.Components.Table.Types as T
import Gargantext.Prelude
import Gargantext.Prelude
import Gargantext.Sessions (Session)
import Gargantext.Sessions (Session)
import Gargantext.Types as GT
import Gargantext.Types as GT
import Gargantext.Utils.SimpleJSON as USJ
import Simple.JSON as JSON
import Simple.JSON as JSON
import Reactix as R
import Reactix as R
import Type.Proxy (Proxy(..))
import Type.Proxy (Proxy(..))
...
@@ -207,14 +209,17 @@ instance JSON.ReadForeign NgramsPatch where
...
@@ -207,14 +209,17 @@ instance JSON.ReadForeign NgramsPatch where
readImpl f = do
readImpl f = do
inst :: { patch_old :: Maybe NgramsRepoElement
inst :: { patch_old :: Maybe NgramsRepoElement
, patch_new :: Maybe NgramsRepoElement
, patch_new :: Maybe NgramsRepoElement
, patch_children ::
PatchSet NgramsTerm
, patch_children ::
Maybe (PatchSet NgramsTerm)
, patch_list ::
Replace GT.TermList
} <- JSON.readImpl f
, patch_list ::
Maybe (Replace GT.TermList)
} <- JSON.readImpl f
-- TODO handle empty fields
-- TODO handle empty fields
-- TODO handle patch_new
-- TODO handle patch_new
if isJust inst.patch_new || isJust inst.patch_old then
if isJust inst.patch_new || isJust inst.patch_old then
pure $ NgramsReplace { patch_old: inst.patch_old, patch_new: inst.patch_new }
pure $ NgramsReplace { patch_old: inst.patch_old
else do
, patch_new: inst.patch_new }
pure $ NgramsPatch { patch_list: inst.patch_list, patch_children: inst.patch_children }
else case (Tuple inst.patch_children inst.patch_list) of
Tuple (Just patch_children) (Just patch_list) ->
pure $ NgramsPatch { patch_list, patch_children }
_ -> USJ.throwJSONError $ F.ForeignError "[readForeign NgramsPatch] patch_children or patch_list undefined"
-----------------------------------------------------
-----------------------------------------------------
newtype NgramsTerm = NormNgramsTerm String
newtype NgramsTerm = NormNgramsTerm String
...
...
src/Gargantext/Utils/SimpleJSON.purs
View file @
cdae18ff
...
@@ -3,9 +3,12 @@ module Gargantext.Utils.SimpleJSON where
...
@@ -3,9 +3,12 @@ module Gargantext.Utils.SimpleJSON where
import Prelude
import Prelude
import Control.Alt ((<|>))
import Control.Alt ((<|>))
import Control.Monad.Except (withExcept)
import Control.Monad.Except (
throwError,
withExcept)
import Data.Generic.Rep as GR
import Data.Generic.Rep as GR
import Data.List as L
import Data.List.Types (NonEmptyList(..))
import Data.Maybe (Maybe(..))
import Data.Maybe (Maybe(..))
import Data.NonEmpty (NonEmpty(..))
import Data.Tuple (Tuple(..))
import Data.Tuple (Tuple(..))
import Foreign (Foreign, ForeignError(..), fail)
import Foreign (Foreign, ForeignError(..), fail)
import Foreign as Foreign
import Foreign as Foreign
...
@@ -86,3 +89,8 @@ instance untaggedSumRepArgument ::
...
@@ -86,3 +89,8 @@ instance untaggedSumRepArgument ::
( JSON.ReadForeign a
( JSON.ReadForeign a
) => UntaggedSumRep (GR.Argument a) where
) => UntaggedSumRep (GR.Argument a) where
untaggedSumRep f = GR.Argument <$> JSON.readImpl f
untaggedSumRep f = GR.Argument <$> JSON.readImpl f
throwJSONError :: forall a. Foreign.ForeignError -> Foreign.F a
throwJSONError err =
throwError $ NonEmptyList $ NonEmpty err L.Nil
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