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
004b6085
Commit
004b6085
authored
Jan 21, 2025
by
Yoelis Acourt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: persist new hyperdata
parent
4ab275a3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
6 deletions
+21
-6
Types.hs
src/Gargantext/API/Node/Document/Export/Types.hs
+1
-0
TSV.hs
src/Gargantext/Core/Text/Corpus/Parsers/TSV.hs
+2
-2
Insert.hs
src/Gargantext/Database/Query/Table/Node/Document/Insert.hs
+18
-4
No files found.
src/Gargantext/API/Node/Document/Export/Types.hs
View file @
004b6085
...
@@ -67,6 +67,7 @@ instance ToNamedRecord Document where
...
@@ -67,6 +67,7 @@ instance ToNamedRecord Document where
,
"Publication Year"
.=
_hd_publication_year
_node_hyperdata
,
"Publication Year"
.=
_hd_publication_year
_node_hyperdata
,
"Authors"
.=
_hd_authors
_node_hyperdata
,
"Authors"
.=
_hd_authors
_node_hyperdata
,
"Title"
.=
_hd_title
_node_hyperdata
,
"Title"
.=
_hd_title
_node_hyperdata
,
"Country"
.=
_hd_from_country
_node_hyperdata
,
"Source"
.=
(
TE
.
encodeUtf8
<$>
_hd_source
_node_hyperdata
)
,
"Source"
.=
(
TE
.
encodeUtf8
<$>
_hd_source
_node_hyperdata
)
,
"Abstract"
.=
(
TE
.
encodeUtf8
<$>
_hd_abstract
_node_hyperdata
)
]
,
"Abstract"
.=
(
TE
.
encodeUtf8
<$>
_hd_abstract
_node_hyperdata
)
]
...
...
src/Gargantext/Core/Text/Corpus/Parsers/TSV.hs
View file @
004b6085
...
@@ -267,7 +267,7 @@ getHeaders bl del = do
...
@@ -267,7 +267,7 @@ getHeaders bl del = do
readTSVFile
::
FilePath
->
IO
(
Either
Text
(
Header
,
Vector
TsvDoc
))
readTSVFile
::
FilePath
->
IO
(
Either
Text
(
Header
,
Vector
TsvDoc
))
readTSVFile
fp
=
do
readTSVFile
fp
=
do
file
<-
BL
.
readFile
fp
file
<-
BL
.
readFile
fp
case
(
testCorrectFile
file
)
of
case
testCorrectFile
file
of
Left
_err
->
pure
$
Left
_err
Left
_err
->
pure
$
Left
_err
Right
del
->
pure
$
readTsvLazyBS
del
file
Right
del
->
pure
$
readTsvLazyBS
del
file
...
@@ -406,7 +406,7 @@ tsv2doc (TsvDoc { .. })
...
@@ -406,7 +406,7 @@ tsv2doc (TsvDoc { .. })
,
_hd_page
=
Nothing
,
_hd_page
=
Nothing
,
_hd_title
=
Just
tsv_title
,
_hd_title
=
Just
tsv_title
,
_hd_authors
=
Just
tsv_authors
,
_hd_authors
=
Just
tsv_authors
,
_hd_from_country
=
Nothing
,
_hd_from_country
=
tsv_from_country
,
_hd_institutes
=
Nothing
,
_hd_institutes
=
Nothing
,
_hd_source
=
Just
tsv_source
,
_hd_source
=
Just
tsv_source
,
_hd_abstract
=
Just
tsv_abstract
,
_hd_abstract
=
Just
tsv_abstract
...
...
src/Gargantext/Database/Query/Table/Node/Document/Insert.hs
View file @
004b6085
...
@@ -73,7 +73,7 @@ import Gargantext.Database.Schema.Node (NodePoly(..))
...
@@ -73,7 +73,7 @@ import Gargantext.Database.Schema.Node (NodePoly(..))
import
Gargantext.Defaults
qualified
as
Defaults
import
Gargantext.Defaults
qualified
as
Defaults
import
Gargantext.Prelude
hiding
(
hash
,
toLower
)
import
Gargantext.Prelude
hiding
(
hash
,
toLower
)
import
Gargantext.Prelude.Crypto.Hash
(
hash
)
import
Gargantext.Prelude.Crypto.Hash
(
hash
)
import
Debug.Pretty.Simple
{-| To Print result query
{-| To Print result query
import Data.ByteString.Internal (ByteString)
import Data.ByteString.Internal (ByteString)
import Database.PostgreSQL.Simple (formatQuery)
import Database.PostgreSQL.Simple (formatQuery)
...
@@ -87,10 +87,24 @@ import Database.PostgreSQL.Simple (formatQuery)
...
@@ -87,10 +87,24 @@ import Database.PostgreSQL.Simple (formatQuery)
-- ParentId : folder ID which is parent of the inserted documents
-- ParentId : folder ID which is parent of the inserted documents
-- Administrator of the database has to create a uniq index as following SQL command:
-- Administrator of the database has to create a uniq index as following SQL command:
-- `create unique index on contexts table (typename, parent_id, (hyperdata ->> 'uniqId'));`
-- `create unique index on contexts table (typename, parent_id, (hyperdata ->> 'uniqId'));`
-- insertDb :: (InsertDb a, HasDBid NodeType) => UserId -> Maybe ParentId -> [a] -> DBCmd err [ReturnId]
-- insertDb u p = pTraceShow ("HELLO", fields) $
-- runPGSQuery queryInsert . Only . Values fields . map (insertDb' u p)
-- where
-- fields = map (QualifiedIdentifier Nothing) inputSqlTypes
insertDb
::
(
InsertDb
a
,
HasDBid
NodeType
)
=>
UserId
->
Maybe
ParentId
->
[
a
]
->
DBCmd
err
[
ReturnId
]
insertDb
::
(
InsertDb
a
,
HasDBid
NodeType
)
=>
UserId
->
Maybe
ParentId
->
[
a
]
->
DBCmd
err
[
ReturnId
]
insertDb
u
p
=
runPGSQuery
queryInsert
.
Only
.
Values
fields
.
map
(
insertDb'
u
p
)
insertDb
userId
parentId
items
=
where
let
fields
=
map
(
QualifiedIdentifier
Nothing
)
inputSqlTypes
preparedItems
=
map
(
insertDb'
userId
parentId
)
items
fields
=
map
(
QualifiedIdentifier
Nothing
)
inputSqlTypes
sqlValues
=
Values
fields
preparedItems
in
pTraceShow
(
"LOOK"
,
preparedItems
)
$
runPGSQuery
queryInsert
(
Only
sqlValues
)
class
InsertDb
a
class
InsertDb
a
where
where
...
...
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