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
160
Issues
160
List
Board
Labels
Milestones
Merge Requests
14
Merge Requests
14
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
be5e9faf
Commit
be5e9faf
authored
Dec 16, 2024
by
Alfredo Di Napoli
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send serialised nodes instead of dummy strings
parent
aff15b60
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
6 deletions
+42
-6
gargantext.cabal
gargantext.cabal
+1
-0
Remote.hs
src/Gargantext/API/Server/Named/Remote.hs
+8
-5
Node.hs
src/Gargantext/Database/Admin/Types/Node.hs
+1
-0
Node.hs
src/Gargantext/Database/Schema/Node.hs
+32
-1
No files found.
gargantext.cabal
View file @
be5e9faf
...
...
@@ -504,6 +504,7 @@ library
, cache >= 0.1.3.0
, case-insensitive ^>= 1.2.1.0
, cassava ^>= 0.5.2.0
, cborg-json >= 0.2
, cereal ^>= 0.5.8.2
, clock >= 0.8
, conduit ^>= 1.3.4.2
...
...
src/Gargantext/API/Server/Named/Remote.hs
View file @
be5e9faf
...
...
@@ -14,20 +14,22 @@ import Control.Exception.Safe qualified as Safe
import
Control.Exception
(
toException
)
import
Control.Lens
(
view
,
(
#
))
import
Control.Monad.Except
(
throwError
)
import
Data.Aeson
qualified
as
JSON
import
Data.ByteString.Builder
qualified
as
B
import
Data.ByteString.Char8
qualified
as
C8
import
Data.ByteString.Lazy
qualified
as
BL
import
Data.Conduit.Combinators
qualified
as
C
import
Data.Conduit.List
qualified
as
CL
import
Gargantext.API.Admin.Auth.Types
(
AuthenticatedUser
)
import
Gargantext.API.Admin.Auth
import
Gargantext.API.Admin.Auth.Types
(
AuthenticatedUser
)
import
Gargantext.API.Auth.PolicyCheck
(
remoteExportChecks
)
import
Gargantext.API.Errors.Types
import
Gargantext.API.Prelude
(
IsGargServer
)
import
Gargantext.API.Routes.Client
(
remoteImportClient
)
import
Gargantext.API.Routes.Named.Remote
qualified
as
Named
import
Gargantext.Core.Config
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Prelude
(
IsDBCmd
)
import
Gargantext.Database.Query.Table.Node
(
getNode
)
import
Prelude
import
Servant.Client.Streaming
(
mkClientEnv
,
withClientM
,
ClientError
)
import
Servant.Server.Generic
(
AsServerT
)
...
...
@@ -42,7 +44,7 @@ remoteAPI authenticatedUser = Named.RemoteAPI $
,
remoteImportEp
=
remoteImportHandler
}
type
ExpectedPayload
=
C8
.
ByteString
-- FIXME(adn)
type
ExpectedPayload
=
[
Node
JSON
.
Value
]
remoteImportHandler
::
(
HasBackendInternalError
err
,
IsDBCmd
env
err
m
,
MonadIO
m
)
=>
ConduitT
()
Named
.
RemoteBinaryData
IO
()
...
...
@@ -60,8 +62,9 @@ remoteExportHandler :: ( MonadIO m, Safe.MonadCatch m
->
m
()
remoteExportHandler
Named
.
RemoteExportRequest
{
..
}
=
do
mgr
<-
view
gargHttpManager
-- FIXME(adn) eventually we want to be sending nodes here.
let
node
=
C8
.
pack
"hello world"
-- FIXME(adn) Here I should somehow need to get all the children of the
-- node so that I can recostruct proper semantic context.
node
<-
(
:
[]
)
<$>
getNode
_rer_node_id
liftIO
(
withClientM
(
remoteImportClient
_rer_instance_auth
(
streamEncoder
node
))
(
mkClientEnv
mgr
_rer_instance_url
)
streamDecode
)
`
Safe
.
catch
`
\
(
e
::
BackendInternalError
)
->
throwError
$
_BackendInternalError
#
e
...
...
src/Gargantext/Database/Admin/Types/Node.hs
View file @
be5e9faf
...
...
@@ -70,6 +70,7 @@ newtype UserId = UnsafeMkUserId { _UserId :: Int }
deriving
newtype
(
ToSchema
,
ToJSON
,
FromJSON
,
FromField
,
ToField
,
Hashable
)
instance
NFData
UserId
where
instance
Serialise
UserId
where
-- The 'UserId' is isomprohic to an 'Int'.
instance
GQLType
UserId
where
...
...
src/Gargantext/Database/Schema/Node.hs
View file @
be5e9faf
...
...
@@ -16,10 +16,13 @@ Portability : POSIX
module
Gargantext.Database.Schema.Node
where
import
Codec.Serialise
import
Codec.CBOR.JSON
qualified
as
CBOR
import
Control.Lens
hiding
(
elements
,
(
&
))
import
Data.Aeson
qualified
as
JSON
import
Gargantext.Database.Schema.Prelude
import
Prelude
hiding
(
null
,
id
,
map
,
sum
)
import
Gargantext.Prelude
(
NFData
(
..
))
import
Prelude
hiding
(
null
,
id
,
map
,
sum
)
------------------------------------------------------------------------
-- Main polymorphic Node definition
...
...
@@ -47,6 +50,34 @@ data NodePoly id
instance
(
NFData
i
,
NFData
h
,
NFData
t
,
NFData
u
,
NFData
p
,
NFData
n
,
NFData
d
,
NFData
hy
)
=>
NFData
(
NodePoly
i
h
t
u
p
n
d
hy
)
where
instance
(
Serialise
i
,
Serialise
h
,
Serialise
t
,
Serialise
u
,
Serialise
p
,
Serialise
n
,
Serialise
d
)
=>
Serialise
(
NodePoly
i
h
t
u
p
n
d
JSON
.
Value
)
where
encode
Node
{
..
}
=
encode
_node_id
<>
encode
_node_hash_id
<>
encode
_node_typename
<>
encode
_node_user_id
<>
encode
_node_parent_id
<>
encode
_node_name
<>
encode
_node_date
<>
CBOR
.
encodeValue
_node_hyperdata
decode
=
do
_node_id
<-
decode
_node_hash_id
<-
decode
_node_typename
<-
decode
_node_user_id
<-
decode
_node_parent_id
<-
decode
_node_name
<-
decode
_node_date
<-
decode
_node_hyperdata
<-
CBOR
.
decodeValue
False
pure
Node
{
..
}
------------------------------------------------------------------------
-- Automatic instances derivation
$
(
deriveJSON
(
unPrefix
"_node_"
)
''
N
odePoly
)
...
...
Przemyslaw Kaminski
@cgenie
mentioned in commit
942e663f
·
Jan 29, 2025
mentioned in commit
942e663f
mentioned in commit 942e663f539b287b4cc0469fe2bcf735813b4ff2
Toggle commit list
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