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
199
Issues
199
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
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
6c513821
Commit
6c513821
authored
May 09, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Date] Date of Node is date of HyperdataDocument.
parent
041ae59f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
Insert.hs
src/Gargantext/Database/Node/Document/Insert.hs
+6
-3
No files found.
src/Gargantext/Database/Node/Document/Insert.hs
View file @
6c513821
...
@@ -63,6 +63,7 @@ import Control.Lens.Prism
...
@@ -63,6 +63,7 @@ import Control.Lens.Prism
import
Control.Lens.Cons
import
Control.Lens.Cons
import
Data.Aeson
(
toJSON
)
import
Data.Aeson
(
toJSON
)
import
Data.Maybe
(
maybe
)
import
Data.Maybe
(
maybe
)
import
Data.Time.Segment
(
jour
)
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
Database.PostgreSQL.Simple
(
FromRow
,
Query
,
Only
(
..
))
import
Database.PostgreSQL.Simple
(
FromRow
,
Query
,
Only
(
..
))
import
Database.PostgreSQL.Simple.FromRow
(
fromRow
,
field
)
import
Database.PostgreSQL.Simple.FromRow
(
fromRow
,
field
)
...
@@ -120,6 +121,7 @@ instance InsertDb HyperdataDocument
...
@@ -120,6 +121,7 @@ instance InsertDb HyperdataDocument
,
toField
u
,
toField
u
,
toField
p
,
toField
p
,
toField
$
maybe
"No Title"
(
DT
.
take
255
)
(
_hyperdataDocument_title
h
)
,
toField
$
maybe
"No Title"
(
DT
.
take
255
)
(
_hyperdataDocument_title
h
)
,
toField
$
_hyperdataDocument_publication_date
h
-- TODO USE UTCTime
,
(
toField
.
toJSON
)
h
,
(
toField
.
toJSON
)
h
]
]
...
@@ -129,6 +131,7 @@ instance InsertDb HyperdataContact
...
@@ -129,6 +131,7 @@ instance InsertDb HyperdataContact
,
toField
u
,
toField
u
,
toField
p
,
toField
p
,
toField
$
maybe
"Contact"
(
DT
.
take
255
)
(
Just
"Name"
)
-- (_hc_name h)
,
toField
$
maybe
"Contact"
(
DT
.
take
255
)
(
Just
"Name"
)
-- (_hc_name h)
,
toField
$
jour
2010
1
1
-- TODO put default date
,
(
toField
.
toJSON
)
h
,
(
toField
.
toJSON
)
h
]
]
...
@@ -147,14 +150,14 @@ insertDocuments_Debug uId pId hs = formatPGSQuery queryInsert (Only $ Values fie
...
@@ -147,14 +150,14 @@ insertDocuments_Debug uId pId hs = formatPGSQuery queryInsert (Only $ Values fie
-- | Input Tables: types of the tables
-- | Input Tables: types of the tables
inputSqlTypes
::
[
Text
]
inputSqlTypes
::
[
Text
]
inputSqlTypes
=
map
DT
.
pack
[
"int4"
,
"int4"
,
"int4"
,
"text"
,
"jsonb"
]
inputSqlTypes
=
map
DT
.
pack
[
"int4"
,
"int4"
,
"int4"
,
"text"
,
"
date"
,
"
jsonb"
]
-- | SQL query to insert documents inside the database
-- | SQL query to insert documents inside the database
queryInsert
::
Query
queryInsert
::
Query
queryInsert
=
[
sql
|
queryInsert
=
[
sql
|
WITH input_rows(typename,user_id,parent_id,name,hyperdata) AS (?)
WITH input_rows(typename,user_id,parent_id,name,
date,
hyperdata) AS (?)
, ins AS (
, ins AS (
INSERT INTO nodes (typename,user_id,parent_id,name,hyperdata)
INSERT INTO nodes (typename,user_id,parent_id,name,
date,
hyperdata)
SELECT * FROM input_rows
SELECT * FROM input_rows
ON CONFLICT ((hyperdata ->> 'uniqIdBdd')) DO NOTHING -- on unique index
ON CONFLICT ((hyperdata ->> 'uniqIdBdd')) DO NOTHING -- on unique index
-- ON CONFLICT (typename, parent_id, (hyperdata ->> 'uniqId')) DO NOTHING -- on unique index
-- ON CONFLICT (typename, parent_id, (hyperdata ->> 'uniqId')) DO NOTHING -- on unique index
...
...
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