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
158
Issues
158
List
Board
Labels
Milestones
Merge Requests
11
Merge Requests
11
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
07e34aa5
Commit
07e34aa5
authored
Jan 04, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into dev-docs-download
parents
ffa3c28d
33bf8ea5
Pipeline
#2313
failed with stage
in 11 minutes and 21 seconds
Changes
48
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
48 changed files
with
452 additions
and
426 deletions
+452
-426
.gitlab-ci.yml
.gitlab-ci.yml
+14
-0
CHANGELOG.md
CHANGELOG.md
+7
-0
package.yaml
package.yaml
+2
-2
Client.hs
src/Gargantext/API/Client.hs
+1
-1
Graph.hs
src/Gargantext/Core/Viz/Graph.hs
+2
-2
Pairing.hs
src/Gargantext/Database/Action/Flow/Pairing.hs
+2
-2
Search.hs
src/Gargantext/Database/Action/Search.hs
+27
-27
Any.hs
src/Gargantext/Database/Admin/Types/Hyperdata/Any.hs
+2
-2
Contact.hs
src/Gargantext/Database/Admin/Types/Hyperdata/Contact.hs
+4
-4
Corpus.hs
src/Gargantext/Database/Admin/Types/Hyperdata/Corpus.hs
+4
-4
Dashboard.hs
src/Gargantext/Database/Admin/Types/Hyperdata/Dashboard.hs
+2
-2
Document.hs
src/Gargantext/Database/Admin/Types/Hyperdata/Document.hs
+4
-4
File.hs
src/Gargantext/Database/Admin/Types/Hyperdata/File.hs
+2
-2
Frame.hs
src/Gargantext/Database/Admin/Types/Hyperdata/Frame.hs
+4
-4
List.hs
src/Gargantext/Database/Admin/Types/Hyperdata/List.hs
+4
-4
Model.hs
src/Gargantext/Database/Admin/Types/Hyperdata/Model.hs
+2
-2
Phylo.hs
src/Gargantext/Database/Admin/Types/Hyperdata/Phylo.hs
+2
-2
Prelude.hs
src/Gargantext/Database/Admin/Types/Hyperdata/Prelude.hs
+1
-1
Texts.hs
src/Gargantext/Database/Admin/Types/Hyperdata/Texts.hs
+2
-2
User.hs
src/Gargantext/Database/Admin/Types/Hyperdata/User.hs
+6
-6
Node.hs
src/Gargantext/Database/Admin/Types/Node.hs
+14
-14
Prelude.hs
src/Gargantext/Database/Prelude.hs
+3
-3
Facet.hs
src/Gargantext/Database/Query/Facet.hs
+39
-40
Filter.hs
src/Gargantext/Database/Query/Filter.hs
+3
-3
Join.hs
src/Gargantext/Database/Query/Join.hs
+47
-41
Ngrams.hs
src/Gargantext/Database/Query/Table/Ngrams.hs
+1
-1
Node.hs
src/Gargantext/Database/Query/Table/Node.hs
+11
-11
Children.hs
src/Gargantext/Database/Query/Table/Node/Children.hs
+1
-1
Select.hs
src/Gargantext/Database/Query/Table/Node/Select.hs
+1
-1
UpdateOpaleye.hs
src/Gargantext/Database/Query/Table/Node/UpdateOpaleye.hs
+1
-1
NodeNode.hs
src/Gargantext/Database/Query/Table/NodeNode.hs
+22
-22
NodeNodeNgrams.hs
src/Gargantext/Database/Query/Table/NodeNodeNgrams.hs
+1
-1
NodeNodeNgrams2.hs
src/Gargantext/Database/Query/Table/NodeNodeNgrams2.hs
+1
-1
Node_NodeNgramsNodeNgrams.hs
...gantext/Database/Query/Table/Node_NodeNgramsNodeNgrams.hs
+1
-1
User.hs
src/Gargantext/Database/Query/Table/User.hs
+9
-9
Root.hs
src/Gargantext/Database/Query/Tree/Root.hs
+2
-2
Ngrams.hs
src/Gargantext/Database/Schema/Ngrams.hs
+13
-13
NgramsPostag.hs
src/Gargantext/Database/Schema/NgramsPostag.hs
+21
-21
Node.hs
src/Gargantext/Database/Schema/Node.hs
+50
-50
NodeNgrams.hs
src/Gargantext/Database/Schema/NodeNgrams.hs
+27
-27
NodeNode.hs
src/Gargantext/Database/Schema/NodeNode.hs
+22
-22
NodeNodeNgrams.hs
src/Gargantext/Database/Schema/NodeNodeNgrams.hs
+15
-15
NodeNodeNgrams2.hs
src/Gargantext/Database/Schema/NodeNodeNgrams2.hs
+9
-9
Node_NodeNgramsNodeNgrams.hs
src/Gargantext/Database/Schema/Node_NodeNgramsNodeNgrams.hs
+12
-12
NodesNgramsRepo.hs
src/Gargantext/Database/Schema/NodesNgramsRepo.hs
+6
-6
Prelude.hs
src/Gargantext/Database/Schema/Prelude.hs
+3
-1
User.hs
src/Gargantext/Database/Schema/User.hs
+21
-21
stack.yaml
stack.yaml
+2
-4
No files found.
.gitlab-ci.yml
View file @
07e34aa5
...
...
@@ -14,9 +14,22 @@ variables:
#- apt-get install make xz-utils
stages
:
-
deps
-
docs
-
test
deps
:
cache
:
# cache per branch name
# key: ${CI_COMMIT_REF_SLUG}
paths
:
-
.stack
-
.stack-root/
-
.stack-work/
-
target
script
:
-
stack build --no-terminal --haddock --no-haddock-deps --only-dependencies --fast
docs
:
cache
:
# cache per branch name
...
...
@@ -47,3 +60,4 @@ test:
-
stack test --no-terminal --fast
# TOOO
CHANGELOG.md
View file @
07e34aa5
## Version 0.0.4.9.9.2
*
[
BACK
]
Opaleye Upgrade
## Version 0.0.4.9.9.1
*
[
FRONT
]
350-dev-graph-search-in-forms-not-labels
*
[
FRONT
]
359-dev-input-with-autocomplete
## Version 0.0.4.9.9
*
[
FIX
]
Continuous Integration (CI)
...
...
package.yaml
View file @
07e34aa5
name
:
gargantext
version
:
'
0.0.4.9.9'
version
:
'
0.0.4.9.9
.2
'
synopsis
:
Search, map, share
description
:
Please see README.md
category
:
Data
...
...
@@ -58,7 +58,7 @@ library:
-
Gargantext.API.Admin.EnvTypes
-
Gargantext.API.Admin.Types
-
Gargantext.API.Prelude
-
Gargantext.Client
-
Gargantext.
API.
Client
-
Gargantext.Core
-
Gargantext.Core.NodeStory
-
Gargantext.Core.Methods.Distances
...
...
src/Gargantext/Client.hs
→
src/Gargantext/
API/
Client.hs
View file @
07e34aa5
{-# OPTIONS_GHC -freduction-depth=0 #-}
{-# OPTIONS_GHC -O0 #-}
module
Gargantext.Client
where
module
Gargantext.
API.
Client
where
import
Data.Int
import
Data.Maybe
...
...
src/Gargantext/Core/Viz/Graph.hs
View file @
07e34aa5
...
...
@@ -191,9 +191,9 @@ instance FromField HyperdataGraph
where
fromField
=
fromField'
instance
DefaultFromField
PG
Jsonb
HyperdataGraph
instance
DefaultFromField
Sql
Jsonb
HyperdataGraph
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
-----------------------------------------------------------
-- This type is used to return graph via API
...
...
src/Gargantext/Database/Action/Flow/Pairing.hs
View file @
07e34aa5
...
...
@@ -52,14 +52,14 @@ import qualified Data.Text as DT
isPairedWith
::
NodeId
->
NodeType
->
Cmd
err
[
NodeId
]
isPairedWith
nId
nt
=
runOpaQuery
(
selectQuery
nt
nId
)
where
selectQuery
::
NodeType
->
NodeId
->
Query
(
Column
PG
Int4
)
selectQuery
::
NodeType
->
NodeId
->
Select
(
Column
Sql
Int4
)
selectQuery
nt'
nId'
=
proc
()
->
do
(
node
,
node_node
)
<-
queryJoin
-<
()
restrict
-<
(
node
^.
node_typename
)
.==
(
sqlInt4
$
toDBid
nt'
)
restrict
-<
(
node_node
^.
nn_node1_id
)
.==
(
toNullable
$
pgNodeId
nId'
)
returnA
-<
node
^.
node_id
queryJoin
::
Query
(
NodeRead
,
NodeNodeReadNull
)
queryJoin
::
Select
(
NodeRead
,
NodeNodeReadNull
)
queryJoin
=
leftJoin2
queryNodeTable
queryNodeNodeTable
cond
where
cond
(
node
,
node_node
)
=
node
^.
node_id
.==
node_node
^.
nn_node2_id
...
...
src/Gargantext/Database/Action/Search.hs
View file @
07e34aa5
...
...
@@ -29,7 +29,7 @@ import Gargantext.Database.Query.Table.NodeNode
import
Gargantext.Database.Schema.Node
import
Gargantext.Prelude
import
Gargantext.Core.Text.Terms.Mono.Stem.En
(
stemIt
)
import
Opaleye
hiding
(
Query
,
Order
)
import
Opaleye
hiding
(
Order
)
import
Data.Profunctor.Product
(
p4
)
import
qualified
Opaleye
as
O
hiding
(
Order
)
...
...
@@ -41,10 +41,10 @@ searchDocInDatabase :: HasDBid NodeType
searchDocInDatabase
_p
t
=
runOpaQuery
(
queryDocInDatabase
t
)
where
-- | Global search query where ParentId is Master Node Corpus Id
queryDocInDatabase
::
Text
->
O
.
Query
(
Column
PGInt4
,
Column
PG
Jsonb
)
queryDocInDatabase
::
Text
->
O
.
Select
(
Column
SqlInt4
,
Column
Sql
Jsonb
)
queryDocInDatabase
q
=
proc
()
->
do
row
<-
queryNodeSearchTable
-<
()
restrict
-<
(
_ns_search
row
)
@@
(
pg
TSQuery
(
unpack
q
))
restrict
-<
(
_ns_search
row
)
@@
(
sql
TSQuery
(
unpack
q
))
restrict
-<
(
_ns_typename
row
)
.==
(
sqlInt4
$
toDBid
NodeDocument
)
returnA
-<
(
_ns_id
row
,
_ns_hyperdata
row
)
...
...
@@ -78,14 +78,14 @@ queryInCorpus :: HasDBid NodeType
=>
CorpusId
->
IsTrash
->
Text
->
O
.
Query
FacetDocRead
->
O
.
Select
FacetDocRead
queryInCorpus
cId
t
q
=
proc
()
->
do
(
n
,
nn
)
<-
joinInCorpus
-<
()
restrict
-<
(
nn
^.
nn_node1_id
)
.==
(
toNullable
$
pgNodeId
cId
)
restrict
-<
if
t
then
(
nn
^.
nn_category
)
.==
(
toNullable
$
sqlInt4
0
)
else
(
nn
^.
nn_category
)
.>=
(
toNullable
$
sqlInt4
1
)
restrict
-<
(
n
^.
ns_search
)
@@
(
pg
TSQuery
(
unpack
q
))
restrict
-<
(
n
^.
ns_search
)
@@
(
sql
TSQuery
(
unpack
q
))
restrict
-<
(
n
^.
ns_typename
)
.==
(
sqlInt4
$
toDBid
NodeDocument
)
returnA
-<
FacetDoc
{
facetDoc_id
=
n
^.
ns_id
,
facetDoc_created
=
n
^.
ns_date
...
...
@@ -96,10 +96,10 @@ queryInCorpus cId t q = proc () -> do
,
facetDoc_score
=
nn
^.
nn_score
}
joinInCorpus
::
O
.
Query
(
NodeSearchRead
,
NodeNodeReadNull
)
joinInCorpus
::
O
.
Select
(
NodeSearchRead
,
NodeNodeReadNull
)
joinInCorpus
=
leftJoin
queryNodeSearchTable
queryNodeNodeTable
cond
where
cond
::
(
NodeSearchRead
,
NodeNodeRead
)
->
Column
PG
Bool
cond
::
(
NodeSearchRead
,
NodeNodeRead
)
->
Column
Sql
Bool
cond
(
n
,
nn
)
=
nn
^.
nn_node2_id
.==
_ns_id
n
------------------------------------------------------------------------
...
...
@@ -125,15 +125,15 @@ selectContactViaDoc
=>
CorpusId
->
AnnuaireId
->
Text
->
Query
Arr
()
(
Column
(
Nullable
PG
Int4
)
,
Column
(
Nullable
PG
Timestamptz
)
,
Column
(
Nullable
PG
Jsonb
)
,
Column
(
Nullable
PG
Int4
)
)
->
Select
Arr
()
(
Column
(
Nullable
Sql
Int4
)
,
Column
(
Nullable
Sql
Timestamptz
)
,
Column
(
Nullable
Sql
Jsonb
)
,
Column
(
Nullable
Sql
Int4
)
)
selectContactViaDoc
cId
aId
q
=
proc
()
->
do
(
doc
,
(
corpus_doc
,
(
_contact_doc
,
(
annuaire_contact
,
contact
))))
<-
queryContactViaDoc
-<
()
restrict
-<
(
doc
^.
ns_search
)
@@
(
pg
TSQuery
$
unpack
q
)
restrict
-<
(
doc
^.
ns_search
)
@@
(
sql
TSQuery
$
unpack
q
)
restrict
-<
(
doc
^.
ns_typename
)
.==
(
sqlInt4
$
toDBid
NodeDocument
)
restrict
-<
(
corpus_doc
^.
nn_node1_id
)
.==
(
toNullable
$
pgNodeId
cId
)
restrict
-<
(
annuaire_contact
^.
nn_node1_id
)
.==
(
toNullable
$
pgNodeId
aId
)
...
...
@@ -155,15 +155,15 @@ selectGroup cId aId q = proc () -> do
returnA
-<
FacetPaired
a
b
c
d
queryContactViaDoc
::
O
.
Query
(
NodeSearchRead
,
(
NodeNodeReadNull
,
(
NodeNodeReadNull
,
(
NodeNodeReadNull
,
NodeReadNull
)
)
)
)
queryContactViaDoc
::
O
.
Select
(
NodeSearchRead
,
(
NodeNodeReadNull
,
(
NodeNodeReadNull
,
(
NodeNodeReadNull
,
NodeReadNull
)
)
)
)
queryContactViaDoc
=
leftJoin5
queryNodeTable
...
...
@@ -176,14 +176,14 @@ queryContactViaDoc =
cond34
cond45
where
cond12
::
(
NodeNodeRead
,
NodeRead
)
->
Column
PG
Bool
cond12
::
(
NodeNodeRead
,
NodeRead
)
->
Column
Sql
Bool
cond12
(
annuaire_contact
,
contact
)
=
contact
^.
node_id
.==
annuaire_contact
^.
nn_node2_id
cond23
::
(
NodeNodeRead
,
(
NodeNodeRead
,
NodeReadNull
)
)
->
Column
PG
Bool
)
->
Column
Sql
Bool
cond23
(
contact_doc
,
(
annuaire_contact
,
_
))
=
contact_doc
^.
nn_node1_id
.==
annuaire_contact
^.
nn_node2_id
cond34
::
(
NodeNodeRead
...
...
@@ -192,7 +192,7 @@ queryContactViaDoc =
,
NodeReadNull
)
)
)
->
Column
PG
Bool
)
->
Column
Sql
Bool
cond34
(
corpus_doc
,
(
contact_doc
,
(
_
,
_
)))
=
corpus_doc
^.
nn_node2_id
.==
contact_doc
^.
nn_node2_id
...
...
@@ -204,7 +204,7 @@ queryContactViaDoc =
)
)
)
)
->
Column
PG
Bool
)
->
Column
Sql
Bool
cond45
(
doc
,
(
corpus_doc
,
(
_
,(
_
,
_
))))
=
doc
^.
ns_id
.==
corpus_doc
^.
nn_node2_id
...
...
src/Gargantext/Database/Admin/Types/Hyperdata/Any.hs
View file @
07e34aa5
...
...
@@ -45,7 +45,7 @@ instance ToSchema HyperdataAny where
instance
FromField
HyperdataAny
where
fromField
=
fromField'
instance
DefaultFromField
PG
Jsonb
HyperdataAny
instance
DefaultFromField
Sql
Jsonb
HyperdataAny
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
src/Gargantext/Database/Admin/Types/Hyperdata/Contact.hs
View file @
07e34aa5
...
...
@@ -194,12 +194,12 @@ instance FromField HyperdataContact where
fromField
=
fromField'
-- | Database (Opaleye instance)
instance
DefaultFromField
PG
Jsonb
HyperdataContact
where
defaultFromField
=
f
ieldQueryRunnerColumn
instance
DefaultFromField
Sql
Jsonb
HyperdataContact
where
defaultFromField
=
f
romPGSFromField
instance
DefaultFromField
(
Nullable
PG
Jsonb
)
HyperdataContact
where
defaultFromField
=
f
ieldQueryRunnerColumn
instance
DefaultFromField
(
Nullable
Sql
Jsonb
)
HyperdataContact
where
defaultFromField
=
f
romPGSFromField
...
...
src/Gargantext/Database/Admin/Types/Hyperdata/Corpus.hs
View file @
07e34aa5
...
...
@@ -90,10 +90,10 @@ instance FromField HyperdataAnnuaire
where
fromField
=
fromField'
------------------------------------------------------------------------
instance
DefaultFromField
PG
Jsonb
HyperdataCorpus
instance
DefaultFromField
Sql
Jsonb
HyperdataCorpus
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
instance
DefaultFromField
PG
Jsonb
HyperdataAnnuaire
instance
DefaultFromField
Sql
Jsonb
HyperdataAnnuaire
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
src/Gargantext/Database/Admin/Types/Hyperdata/Dashboard.hs
View file @
07e34aa5
...
...
@@ -71,7 +71,7 @@ instance ToSchema HyperdataDashboard where
instance
FromField
HyperdataDashboard
where
fromField
=
fromField'
instance
DefaultFromField
PG
Jsonb
HyperdataDashboard
instance
DefaultFromField
Sql
Jsonb
HyperdataDashboard
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
src/Gargantext/Database/Admin/Types/Hyperdata/Document.hs
View file @
07e34aa5
...
...
@@ -202,11 +202,11 @@ instance ToField HyperdataDocumentV3 where
toField
=
toJSONField
------------------------------------------------------------------------
instance
DefaultFromField
PG
Jsonb
HyperdataDocument
instance
DefaultFromField
Sql
Jsonb
HyperdataDocument
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
instance
DefaultFromField
PG
Jsonb
HyperdataDocumentV3
instance
DefaultFromField
Sql
Jsonb
HyperdataDocumentV3
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
------------------------------------------------------------------------
src/Gargantext/Database/Admin/Types/Hyperdata/File.hs
View file @
07e34aa5
...
...
@@ -54,9 +54,9 @@ instance FromField HyperdataFile
where
fromField
=
fromField'
instance
DefaultFromField
PG
Jsonb
HyperdataFile
instance
DefaultFromField
Sql
Jsonb
HyperdataFile
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
instance
ToSchema
HyperdataFile
where
declareNamedSchema
proxy
=
...
...
src/Gargantext/Database/Admin/Types/Hyperdata/Frame.hs
View file @
07e34aa5
...
...
@@ -23,10 +23,10 @@ module Gargantext.Database.Admin.Types.Hyperdata.Frame
import
Control.Lens
import
Data.ByteString.Lazy
(
toStrict
)
import
qualified
Data.Text
as
T
import
Data.Text.Encoding
(
decodeUtf8
)
import
Gargantext.Prelude
import
Gargantext.Database.Admin.Types.Hyperdata.Prelude
import
Gargantext.Prelude
import
qualified
Data.Text
as
T
import
qualified
Network.Wreq
as
Wreq
------------------------------------------------------------------------
...
...
@@ -58,9 +58,9 @@ instance FromField HyperdataFrame
where
fromField
=
fromField'
instance
DefaultFromField
PG
Jsonb
HyperdataFrame
instance
DefaultFromField
Sql
Jsonb
HyperdataFrame
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
instance
ToSchema
HyperdataFrame
where
declareNamedSchema
proxy
=
...
...
src/Gargantext/Database/Admin/Types/Hyperdata/List.hs
View file @
07e34aa5
...
...
@@ -98,12 +98,12 @@ instance FromField HyperdataListCooc
where
fromField
=
fromField'
instance
DefaultFromField
PG
Jsonb
HyperdataList
instance
DefaultFromField
Sql
Jsonb
HyperdataList
where
defaultFromField
=
f
ieldQueryRunnerColumn
instance
DefaultFromField
PG
Jsonb
HyperdataListCooc
defaultFromField
=
f
romPGSFromField
instance
DefaultFromField
Sql
Jsonb
HyperdataListCooc
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
instance
ToSchema
HyperdataList
where
...
...
src/Gargantext/Database/Admin/Types/Hyperdata/Model.hs
View file @
07e34aa5
...
...
@@ -48,9 +48,9 @@ instance FromField HyperdataModel
where
fromField
=
fromField'
instance
DefaultFromField
PG
Jsonb
HyperdataModel
instance
DefaultFromField
Sql
Jsonb
HyperdataModel
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
instance
ToSchema
HyperdataModel
where
declareNamedSchema
proxy
=
...
...
src/Gargantext/Database/Admin/Types/Hyperdata/Phylo.hs
View file @
07e34aa5
...
...
@@ -56,6 +56,6 @@ instance ToSchema HyperdataPhylo where
instance
FromField
HyperdataPhylo
where
fromField
=
fromField'
instance
DefaultFromField
PG
Jsonb
HyperdataPhylo
instance
DefaultFromField
Sql
Jsonb
HyperdataPhylo
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
src/Gargantext/Database/Admin/Types/Hyperdata/Prelude.hs
View file @
07e34aa5
...
...
@@ -48,7 +48,7 @@ import GHC.Generics (Generic)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
,
wellNamedSchema
)
import
Gargantext.Database.Prelude
(
fromField'
)
import
Gargantext.Prelude
import
Opaleye
(
DefaultFromField
,
defaultFromField
,
PGJsonb
,
fieldQueryRunnerColumn
,
Nullable
)
import
Opaleye
(
DefaultFromField
,
defaultFromField
,
Nullable
,
SqlJsonb
,
fromPGSFromField
)
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
hiding
(
vector
)
...
...
src/Gargantext/Database/Admin/Types/Hyperdata/Texts.hs
View file @
07e34aa5
...
...
@@ -54,7 +54,7 @@ instance ToSchema HyperdataTexts where
instance
FromField
HyperdataTexts
where
fromField
=
fromField'
instance
DefaultFromField
PG
Jsonb
HyperdataTexts
instance
DefaultFromField
Sql
Jsonb
HyperdataTexts
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
src/Gargantext/Database/Admin/Types/Hyperdata/User.hs
View file @
07e34aa5
...
...
@@ -135,12 +135,12 @@ instance FromField HyperdataPublic where
fromField
=
fromField'
-- | Database (Opaleye instance)
instance
DefaultFromField
PG
Jsonb
HyperdataUser
where
defaultFromField
=
f
ieldQueryRunnerColumn
instance
DefaultFromField
Sql
Jsonb
HyperdataUser
where
defaultFromField
=
f
romPGSFromField
instance
DefaultFromField
PG
Jsonb
HyperdataPrivate
where
defaultFromField
=
f
ieldQueryRunnerColumn
instance
DefaultFromField
Sql
Jsonb
HyperdataPrivate
where
defaultFromField
=
f
romPGSFromField
instance
DefaultFromField
PG
Jsonb
HyperdataPublic
where
defaultFromField
=
f
ieldQueryRunnerColumn
instance
DefaultFromField
Sql
Jsonb
HyperdataPublic
where
defaultFromField
=
f
romPGSFromField
src/Gargantext/Database/Admin/Types/Node.hs
View file @
07e34aa5
...
...
@@ -35,7 +35,7 @@ import Database.PostgreSQL.Simple.ToField (ToField, toField)
import
GHC.Generics
(
Generic
)
import
Servant
import
qualified
Opaleye
as
O
import
Opaleye
(
DefaultFromField
,
defaultFromField
,
PGInt4
,
PGText
,
PGTSVector
,
Nullable
,
fieldQueryRunnerColumn
)
import
Opaleye
(
DefaultFromField
,
defaultFromField
,
SqlInt4
,
SqlText
,
SqlTSVector
,
Nullable
,
fromPGSFromField
)
import
Test.QuickCheck
(
elements
)
import
Gargantext.Prelude.Crypto.Hash
(
Hash
)
import
Test.QuickCheck.Arbitrary
...
...
@@ -145,7 +145,7 @@ instance (Arbitrary hyperdata
<*>
arbitrary
------------------------------------------------------------------------
pgNodeId
::
NodeId
->
O
.
Column
O
.
PG
Int4
pgNodeId
::
NodeId
->
O
.
Column
O
.
Sql
Int4
pgNodeId
=
O
.
sqlInt4
.
id2int
where
id2int
::
NodeId
->
Int
...
...
@@ -360,28 +360,28 @@ instance FromField (NodeId, Text)
fromField = fromField'
-}
------------------------------------------------------------------------
instance
DefaultFromField
PG
TSVector
(
Maybe
TSVector
)
instance
DefaultFromField
Sql
TSVector
(
Maybe
TSVector
)
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
instance
DefaultFromField
PG
Int4
(
Maybe
NodeId
)
instance
DefaultFromField
Sql
Int4
(
Maybe
NodeId
)
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
instance
DefaultFromField
PG
Int4
NodeId
instance
DefaultFromField
Sql
Int4
NodeId
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
instance
DefaultFromField
(
Nullable
PG
Int4
)
NodeId
instance
DefaultFromField
(
Nullable
Sql
Int4
)
NodeId
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
instance
(
DefaultFromField
(
Nullable
O
.
PG
Timestamptz
)
UTCTime
)
instance
(
DefaultFromField
(
Nullable
O
.
Sql
Timestamptz
)
UTCTime
)
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
instance
DefaultFromField
PG
Text
(
Maybe
Hash
)
instance
DefaultFromField
Sql
Text
(
Maybe
Hash
)
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
src/Gargantext/Database/Prelude.hs
View file @
07e34aa5
...
...
@@ -32,7 +32,7 @@ import Database.PostgreSQL.Simple.Internal (Field)
import
Gargantext.Core.Mail.Types
(
HasMail
)
import
Gargantext.Prelude
import
Gargantext.Prelude.Config
(
readIniFile'
,
val
)
import
Opaleye
(
Query
,
Unpackspec
,
showSql
,
FromFields
,
Select
,
runSelect
,
PG
Jsonb
,
DefaultFromField
)
import
Opaleye
(
Unpackspec
,
showSql
,
FromFields
,
Select
,
runSelect
,
Sql
Jsonb
,
DefaultFromField
)
import
Opaleye.Aggregate
(
countRows
)
import
System.IO
(
FilePath
)
import
System.IO
(
stderr
)
...
...
@@ -57,7 +57,7 @@ instance HasConfig GargConfig where
hasConfig
=
identity
-------------------------------------------------------
type
JSONB
=
DefaultFromField
PG
Jsonb
type
JSONB
=
DefaultFromField
Sql
Jsonb
-------------------------------------------------------
type
CmdM''
env
err
m
=
...
...
@@ -185,6 +185,6 @@ fromField' field mb = do
,
show
v
]
printSqlOpa
::
Default
Unpackspec
a
a
=>
Query
a
->
IO
()
printSqlOpa
::
Default
Unpackspec
a
a
=>
Select
a
->
IO
()
printSqlOpa
=
putStrLn
.
maybe
"Empty query"
identity
.
showSql
src/Gargantext/Database/Query/Facet.hs
View file @
07e34aa5
...
...
@@ -8,8 +8,7 @@ Stability : experimental
Portability : POSIX
-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FunctionalDependencies #-}
...
...
@@ -152,28 +151,28 @@ instance ( Arbitrary id
)
=>
Arbitrary
(
FacetPaired
id
date
hyperdata
score
)
where
arbitrary
=
FacetPaired
<$>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
type
FacetPairedRead
=
FacetPaired
(
Column
PG
Int4
)
(
Column
PG
Timestamptz
)
(
Column
PG
Jsonb
)
(
Column
PG
Int4
)
type
FacetPairedRead
=
FacetPaired
(
Column
Sql
Int4
)
(
Column
Sql
Timestamptz
)
(
Column
Sql
Jsonb
)
(
Column
Sql
Int4
)
type
FacetPairedReadNull
=
FacetPaired
(
Column
(
Nullable
PG
Int4
)
)
(
Column
(
Nullable
PG
Timestamptz
))
(
Column
(
Nullable
PG
Jsonb
)
)
(
Column
(
Nullable
PG
Int4
)
)
type
FacetPairedReadNull
=
FacetPaired
(
Column
(
Nullable
Sql
Int4
)
)
(
Column
(
Nullable
Sql
Timestamptz
))
(
Column
(
Nullable
Sql
Jsonb
)
)
(
Column
(
Nullable
Sql
Int4
)
)
type
FacetPairedReadNullAgg
=
FacetPaired
(
Aggregator
(
Column
(
Nullable
PG
Int4
)
)
(
Column
(
Nullable
PG
Int4
)
)
type
FacetPairedReadNullAgg
=
FacetPaired
(
Aggregator
(
Column
(
Nullable
Sql
Int4
)
)
(
Column
(
Nullable
Sql
Int4
)
)
)
(
Aggregator
(
Column
(
Nullable
PG
Timestamptz
))
(
Column
(
Nullable
PG
Timestamptz
))
(
Aggregator
(
Column
(
Nullable
Sql
Timestamptz
))
(
Column
(
Nullable
Sql
Timestamptz
))
)
(
Aggregator
(
Column
(
Nullable
PG
Jsonb
)
)
(
Column
(
Nullable
PG
Jsonb
)
)
(
Aggregator
(
Column
(
Nullable
Sql
Jsonb
)
)
(
Column
(
Nullable
Sql
Jsonb
)
)
)
(
Aggregator
(
Column
(
Nullable
PG
Int4
)
)
(
Column
(
Nullable
PG
Int4
)
)
(
Aggregator
(
Column
(
Nullable
Sql
Int4
)
)
(
Column
(
Nullable
Sql
Int4
)
)
)
...
...
@@ -203,13 +202,13 @@ instance Arbitrary FacetDoc where
$
(
makeAdaptorAndInstance
"pFacetDoc"
''
F
acet
)
-- $(makeLensesWith abbreviatedFields ''Facet)
type
FacetDocRead
=
Facet
(
Column
PG
Int4
)
(
Column
PG
Timestamptz
)
(
Column
PG
Text
)
(
Column
PG
Jsonb
)
(
Column
(
Nullable
PG
Int4
))
-- Category
(
Column
(
Nullable
PG
Float8
))
-- Ngrams Count
(
Column
(
Nullable
PG
Float8
))
-- Score
type
FacetDocRead
=
Facet
(
Column
Sql
Int4
)
(
Column
Sql
Timestamptz
)
(
Column
Sql
Text
)
(
Column
Sql
Jsonb
)
(
Column
(
Nullable
Sql
Int4
))
-- Category
(
Column
(
Nullable
Sql
Float8
))
-- Ngrams Count
(
Column
(
Nullable
Sql
Float8
))
-- Score
-----------------------------------------------------------------------
-----------------------------------------------------------------------
...
...
@@ -261,13 +260,13 @@ viewAuthorsDoc :: HasDBid NodeType
=>
ContactId
->
IsTrash
->
NodeType
->
Query
FacetDocRead
->
Select
FacetDocRead
viewAuthorsDoc
cId
_
nt
=
proc
()
->
do
(
doc
,(
_
,(
_
,(
_
,
contact'
))))
<-
queryAuthorsDoc
-<
()
{-nn <- queryNodeNodeTable -< ()
restrict -< nn_node1_id nn .== _node_id doc
-- restrict -< nn_delete nn .== (
pg
Bool t)
-- restrict -< nn_delete nn .== (
sql
Bool t)
-}
restrict
-<
_node_id
contact'
.==
(
toNullable
$
pgNodeId
cId
)
...
...
@@ -278,24 +277,24 @@ viewAuthorsDoc cId _ nt = proc () -> do
,
facetDoc_title
=
_node_name
doc
,
facetDoc_hyperdata
=
_node_hyperdata
doc
,
facetDoc_category
=
toNullable
$
sqlInt4
1
,
facetDoc_ngramCount
=
toNullable
$
pg
Double
1
,
facetDoc_score
=
toNullable
$
pg
Double
1
}
,
facetDoc_ngramCount
=
toNullable
$
sql
Double
1
,
facetDoc_score
=
toNullable
$
sql
Double
1
}
queryAuthorsDoc
::
Query
(
NodeRead
,
(
NodeNodeNgramsReadNull
,
(
NgramsReadNull
,
(
NodeNodeNgramsReadNull
,
NodeReadNull
))))
queryAuthorsDoc
::
Select
(
NodeRead
,
(
NodeNodeNgramsReadNull
,
(
NgramsReadNull
,
(
NodeNodeNgramsReadNull
,
NodeReadNull
))))
queryAuthorsDoc
=
leftJoin5
queryNodeTable
queryNodeNodeNgramsTable
queryNgramsTable
queryNodeNodeNgramsTable
queryNodeTable
cond12
cond23
cond34
cond45
where
cond12
::
(
NodeNodeNgramsRead
,
NodeRead
)
->
Column
PG
Bool
cond12
::
(
NodeNodeNgramsRead
,
NodeRead
)
->
Column
Sql
Bool
cond12
(
nodeNgram
,
doc
)
=
_node_id
doc
.==
_nnng_node1_id
nodeNgram
cond23
::
(
NgramsRead
,
(
NodeNodeNgramsRead
,
NodeReadNull
))
->
Column
PG
Bool
cond23
::
(
NgramsRead
,
(
NodeNodeNgramsRead
,
NodeReadNull
))
->
Column
Sql
Bool
cond23
(
ngrams'
,
(
nodeNgram
,
_
))
=
ngrams'
^.
ngrams_id
.==
_nnng_ngrams_id
nodeNgram
cond34
::
(
NodeNodeNgramsRead
,
(
NgramsRead
,
(
NodeNodeNgramsReadNull
,
NodeReadNull
)))
->
Column
PG
Bool
cond34
::
(
NodeNodeNgramsRead
,
(
NgramsRead
,
(
NodeNodeNgramsReadNull
,
NodeReadNull
)))
->
Column
Sql
Bool
cond34
(
nodeNgram2
,
(
ngrams'
,
(
_
,
_
)))
=
ngrams'
^.
ngrams_id
.==
_nnng_ngrams_id
nodeNgram2
cond45
::
(
NodeRead
,
(
NodeNodeNgramsRead
,
(
NgramsReadNull
,
(
NodeNodeNgramsReadNull
,
NodeReadNull
))))
->
Column
PG
Bool
cond45
::
(
NodeRead
,
(
NodeNodeNgramsRead
,
(
NgramsReadNull
,
(
NodeNodeNgramsReadNull
,
NodeReadNull
))))
->
Column
Sql
Bool
cond45
(
contact'
,
(
nodeNgram2'
,
(
_
,
(
_
,
_
))))
=
_node_id
contact'
.==
_nnng_node1_id
nodeNgram2'
--}
...
...
@@ -346,7 +345,7 @@ viewDocuments :: CorpusId
->
IsTrash
->
NodeTypeId
->
Maybe
Text
->
Query
FacetDocRead
->
Select
FacetDocRead
viewDocuments
cId
t
ntId
mQuery
=
viewDocumentsQuery
cId
t
ntId
mQuery
>>>
proc
(
n
,
nn
)
->
do
returnA
-<
FacetDoc
{
facetDoc_id
=
_ns_id
n
,
facetDoc_created
=
_ns_date
n
...
...
@@ -360,7 +359,7 @@ viewDocuments' :: CorpusId
->
IsTrash
->
NodeTypeId
->
Maybe
Text
->
Query
NodeRead
->
Select
NodeRead
viewDocuments'
cId
t
ntId
mQuery
=
viewDocumentsQuery
cId
t
ntId
mQuery
>>>
proc
(
n
,
_nn
)
->
do
returnA
-<
Node
{
_node_id
=
_ns_id
n
,
_node_hash_id
=
""
...
...
@@ -375,7 +374,7 @@ viewDocumentsQuery :: CorpusId
->
IsTrash
->
NodeTypeId
->
Maybe
Text
->
Query
(
NodeSearchRead
,
NodeNodeRead
)
->
Select
(
NodeSearchRead
,
NodeNodeRead
)
viewDocumentsQuery
cId
t
ntId
mQuery
=
proc
()
->
do
n
<-
queryNodeSearchTable
-<
()
nn
<-
queryNodeNodeTable
-<
()
...
...
@@ -389,7 +388,7 @@ viewDocumentsQuery cId t ntId mQuery = proc () -> do
-- iLikeQuery = T.intercalate "" ["%", query, "%"]
-- restrict -< (n^.node_name) `ilike` (sqlStrictText iLikeQuery)
restrict
-<
if
query
==
""
then
pg
Bool
True
then
sql
Bool
True
--else (n^.ns_search) @@ (pgTSQuery (T.unpack query))
else
(
n
^.
ns_search
)
@@
(
plaintoTSQuery
$
T
.
unpack
query
)
...
...
@@ -424,5 +423,5 @@ orderWith _ = asc facetDoc_created
facetDoc_source
::
SqlIsJson
a
=>
Facet
id
created
title
(
Column
a
)
favorite
ngramCount
score
->
Column
(
Nullable
PG
Text
)
facetDoc_source
x
=
toNullable
(
facetDoc_hyperdata
x
)
.->>
pg
String
"source"
->
Column
(
Nullable
Sql
Text
)
facetDoc_source
x
=
toNullable
(
facetDoc_hyperdata
x
)
.->>
sql
String
"source"
src/Gargantext/Database/Query/Filter.hs
View file @
07e34aa5
...
...
@@ -20,12 +20,12 @@ module Gargantext.Database.Query.Filter
import
Gargantext.Core.Types
(
Limit
,
Offset
)
import
Data.Maybe
(
Maybe
,
maybe
)
import
Opaleye
(
Query
,
limit
,
offset
)
import
Opaleye
(
Select
,
limit
,
offset
)
limit'
::
Maybe
Limit
->
Query
a
->
Query
a
limit'
::
Maybe
Limit
->
Select
a
->
Select
a
limit'
maybeLimit
query
=
maybe
query
(
\
l
->
limit
l
query
)
maybeLimit
offset'
::
Maybe
Offset
->
Query
a
->
Query
a
offset'
::
Maybe
Offset
->
Select
a
->
Select
a
offset'
maybeOffset
query
=
maybe
query
(
\
o
->
offset
o
query
)
maybeOffset
src/Gargantext/Database/Query/Join.hs
View file @
07e34aa5
...
...
@@ -33,28 +33,34 @@ module Gargantext.Database.Query.Join ( leftJoin2
)
where
import
Control.Arrow
((
>>>
))
import
Control.Arrow
((
>>>
)
,
returnA
)
import
Data.Profunctor.Product.Default
import
Gargantext.Prelude
import
Opaleye
import
Opaleye
hiding
(
keepWhen
)
import
Opaleye.Internal.Join
(
NullMaker
(
..
))
import
qualified
Opaleye.Internal.Unpackspec
()
keepWhen
::
(
a
->
Field
SqlBool
)
->
SelectArr
a
a
keepWhen
p
=
proc
a
->
do
restrict
-<
p
a
returnA
-<
a
------------------------------------------------------------------------
leftJoin2
::
(
Default
Unpackspec
fieldsL
fieldsL
,
Default
Unpackspec
fieldsR
fieldsR
,
Default
NullMaker
fieldsR
nullableFieldsR
)
=>
Select
fieldsL
->
Select
fieldsR
->
((
fieldsL
,
fieldsR
)
->
Column
PG
Bool
)
->
((
fieldsL
,
fieldsR
)
->
Column
Sql
Bool
)
->
Select
(
fieldsL
,
nullableFieldsR
)
leftJoin2
=
leftJoin
------------------------------------------------------------------------
-- | LeftJoin3 in two ways to write it
_leftJoin3
::
Query
columnsA
->
Query
columnsB
->
Query
columnsC
->
((
columnsA
,
columnsB
,
columnsC
)
->
Column
PG
Bool
)
->
Query
(
columnsA
,
columnsB
,
columnsC
)
_leftJoin3
::
Select
columnsA
->
Select
columnsB
->
Select
columnsC
->
((
columnsA
,
columnsB
,
columnsC
)
->
Column
Sql
Bool
)
->
Select
(
columnsA
,
columnsB
,
columnsC
)
_leftJoin3
q1
q2
q3
cond
=
((,,)
<$>
q1
<*>
q2
<*>
q3
)
>>>
keepWhen
cond
...
...
@@ -68,8 +74,8 @@ leftJoin3 :: ( Default Unpackspec b2 b2
Select
fieldsR
->
Select
b3
->
Select
fieldsL
->
((
b3
,
fieldsR
)
->
Column
PG
Bool
)
->
((
fieldsL
,
(
b3
,
b2
))
->
Column
PG
Bool
)
->
((
b3
,
fieldsR
)
->
Column
Sql
Bool
)
->
((
fieldsL
,
(
b3
,
b2
))
->
Column
Sql
Bool
)
->
Select
(
fieldsL
,
(
b4
,
b5
))
leftJoin3
q1
q2
q3
...
...
@@ -88,9 +94,9 @@ leftJoin4 :: (Default Unpackspec b2 b2,
->
Select
b3
->
Select
b2
->
Select
fieldsL
->
((
b3
,
fieldsR
)
->
Column
PG
Bool
)
->
((
b2
,
(
b3
,
b4
))
->
Column
PG
Bool
)
->
((
fieldsL
,
(
b2
,
(
b5
,
b6
)))
->
Column
PG
Bool
)
->
((
b3
,
fieldsR
)
->
Column
Sql
Bool
)
->
((
b2
,
(
b3
,
b4
))
->
Column
Sql
Bool
)
->
((
fieldsL
,
(
b2
,
(
b5
,
b6
)))
->
Column
Sql
Bool
)
->
Select
(
fieldsL
,
(
b7
,
(
b8
,
b9
)))
leftJoin4
q1
q2
q3
q4
cond12
cond23
cond34
=
...
...
@@ -117,10 +123,10 @@ leftJoin5 :: (Default Unpackspec b2 b2, Default Unpackspec b3 b3,
->
Select
b7
->
Select
b8
->
Select
fieldsL
->
((
b5
,
fieldsR
)
->
Column
PG
Bool
)
->
((
b7
,
(
b5
,
b4
))
->
Column
PG
Bool
)
->
((
b8
,
(
b7
,
(
b9
,
b10
)))
->
Column
PG
Bool
)
->
((
fieldsL
,
(
b8
,
(
b6
,
(
b3
,
b2
))))
->
Column
PG
Bool
)
->
((
b5
,
fieldsR
)
->
Column
Sql
Bool
)
->
((
b7
,
(
b5
,
b4
))
->
Column
Sql
Bool
)
->
((
b8
,
(
b7
,
(
b9
,
b10
)))
->
Column
Sql
Bool
)
->
((
fieldsL
,
(
b8
,
(
b6
,
(
b3
,
b2
))))
->
Column
Sql
Bool
)
->
Select
(
fieldsL
,
(
b12
,
(
b11
,
(
b13
,
b14
))))
leftJoin5
q1
q2
q3
q4
q5
cond12
cond23
cond34
cond45
=
...
...
@@ -155,11 +161,11 @@ leftJoin6 :: (Default Unpackspec b2 b2, Default Unpackspec b3 b3,
->
Select
b5
->
Select
b6
->
Select
fieldsL
->
((
b8
,
fieldsR
)
->
Column
PG
Bool
)
->
((
b3
,
(
b8
,
b9
))
->
Column
PG
Bool
)
->
((
b5
,
(
b3
,
(
b14
,
b15
)))
->
Column
PG
Bool
)
->
((
b6
,
(
b5
,
(
b7
,
(
b10
,
b11
))))
->
Column
PG
Bool
)
->
((
fieldsL
,
(
b6
,
(
b4
,
(
b2
,
(
b12
,
b13
)))))
->
Column
PG
Bool
)
->
((
b8
,
fieldsR
)
->
Column
Sql
Bool
)
->
((
b3
,
(
b8
,
b9
))
->
Column
Sql
Bool
)
->
((
b5
,
(
b3
,
(
b14
,
b15
)))
->
Column
Sql
Bool
)
->
((
b6
,
(
b5
,
(
b7
,
(
b10
,
b11
))))
->
Column
Sql
Bool
)
->
((
fieldsL
,
(
b6
,
(
b4
,
(
b2
,
(
b12
,
b13
)))))
->
Column
Sql
Bool
)
->
Select
(
fieldsL
,
(
b17
,
(
b16
,
(
b18
,
(
b19
,
b20
)))))
leftJoin6
q1
q2
q3
q4
q5
q6
cond12
cond23
cond34
cond45
cond56
=
...
...
@@ -203,13 +209,13 @@ leftJoin7 :: (Default Unpackspec b2 b2, Default Unpackspec b3 b3,
->
Select
b14
->
Select
b13
->
Select
fieldsL
->
((
b7
,
fieldsR
)
->
Column
PG
Bool
)
->
((
b11
,
(
b7
,
b6
))
->
Column
PG
Bool
)
->
((
b16
,
(
b11
,
(
b20
,
b21
)))
->
Column
PG
Bool
)
->
((
b14
,
(
b16
,
(
b8
,
(
b5
,
b4
))))
->
Column
PG
Bool
)
->
((
b13
,
(
b14
,
(
b12
,
(
b10
,
(
b18
,
b19
)))))
->
Column
PG
Bool
)
->
((
b7
,
fieldsR
)
->
Column
Sql
Bool
)
->
((
b11
,
(
b7
,
b6
))
->
Column
Sql
Bool
)
->
((
b16
,
(
b11
,
(
b20
,
b21
)))
->
Column
Sql
Bool
)
->
((
b14
,
(
b16
,
(
b8
,
(
b5
,
b4
))))
->
Column
Sql
Bool
)
->
((
b13
,
(
b14
,
(
b12
,
(
b10
,
(
b18
,
b19
)))))
->
Column
Sql
Bool
)
->
((
fieldsL
,
(
b13
,
(
b15
,
(
b17
,
(
b9
,
(
b3
,
b2
))))))
->
Column
PG
Bool
)
->
Column
Sql
Bool
)
->
Select
(
fieldsL
,
(
b24
,
(
b25
,
(
b23
,
(
b22
,
(
b26
,
b27
))))))
leftJoin7
q1
q2
q3
q4
q5
q6
q7
cond12
cond23
cond34
cond45
cond56
cond67
=
...
...
@@ -263,14 +269,14 @@ leftJoin8 :: (Default Unpackspec b2 b2, Default Unpackspec b3 b3,
->
Select
b11
->
Select
b10
->
Select
fieldsL
->
((
b17
,
fieldsR
)
->
Column
PG
Bool
)
->
((
b4
,
(
b17
,
b18
))
->
Column
PG
Bool
)
->
((
b8
,
(
b4
,
(
b27
,
b28
)))
->
Column
PG
Bool
)
->
((
b13
,
(
b8
,
(
b16
,
(
b19
,
b20
))))
->
Column
PG
Bool
)
->
((
b11
,
(
b13
,
(
b5
,
(
b3
,
(
b25
,
b26
)))))
->
Column
PG
Bool
)
->
((
b10
,
(
b11
,
(
b9
,
(
b7
,
(
b15
,
(
b21
,
b22
))))))
->
Column
PG
Bool
)
->
((
b17
,
fieldsR
)
->
Column
Sql
Bool
)
->
((
b4
,
(
b17
,
b18
))
->
Column
Sql
Bool
)
->
((
b8
,
(
b4
,
(
b27
,
b28
)))
->
Column
Sql
Bool
)
->
((
b13
,
(
b8
,
(
b16
,
(
b19
,
b20
))))
->
Column
Sql
Bool
)
->
((
b11
,
(
b13
,
(
b5
,
(
b3
,
(
b25
,
b26
)))))
->
Column
Sql
Bool
)
->
((
b10
,
(
b11
,
(
b9
,
(
b7
,
(
b15
,
(
b21
,
b22
))))))
->
Column
Sql
Bool
)
->
((
fieldsL
,
(
b10
,
(
b12
,
(
b14
,
(
b6
,
(
b2
,
(
b23
,
b24
)))))))
->
Column
PG
Bool
)
->
Column
Sql
Bool
)
->
Select
(
fieldsL
,
(
b31
,
(
b32
,
(
b30
,
(
b29
,
(
b33
,
(
b34
,
b35
)))))))
leftJoin8
q1
q2
q3
q4
q5
q6
q7
q8
cond12
cond23
cond34
cond45
cond56
cond67
cond78
=
...
...
@@ -336,16 +342,16 @@ leftJoin9 :: (Default Unpackspec b2 b2, Default Unpackspec b3 b3,
->
Select
b21
->
Select
b22
->
Select
fieldsL
->
((
b9
,
fieldsR
)
->
Column
PG
Bool
)
->
((
b15
,
(
b9
,
b8
))
->
Column
PG
Bool
)
->
((
b28
,
(
b15
,
(
b35
,
b36
)))
->
Column
PG
Bool
)
->
((
b24
,
(
b28
,
(
b10
,
(
b7
,
b6
))))
->
Column
PG
Bool
)
->
((
b19
,
(
b24
,
(
b16
,
(
b14
,
(
b33
,
b34
)))))
->
Column
PG
Bool
)
->
((
b21
,
(
b19
,
(
b27
,
(
b29
,
(
b11
,
(
b5
,
b4
))))))
->
Column
PG
Bool
)
->
((
b9
,
fieldsR
)
->
Column
Sql
Bool
)
->
((
b15
,
(
b9
,
b8
))
->
Column
Sql
Bool
)
->
((
b28
,
(
b15
,
(
b35
,
b36
)))
->
Column
Sql
Bool
)
->
((
b24
,
(
b28
,
(
b10
,
(
b7
,
b6
))))
->
Column
Sql
Bool
)
->
((
b19
,
(
b24
,
(
b16
,
(
b14
,
(
b33
,
b34
)))))
->
Column
Sql
Bool
)
->
((
b21
,
(
b19
,
(
b27
,
(
b29
,
(
b11
,
(
b5
,
b4
))))))
->
Column
Sql
Bool
)
->
((
b22
,
(
b21
,
(
b23
,
(
b25
,
(
b17
,
(
b13
,
(
b31
,
b32
)))))))
->
Column
PG
Bool
)
->
Column
Sql
Bool
)
->
((
fieldsL
,
(
b22
,
(
b20
,
(
b18
,
(
b26
,
(
b30
,
(
b12
,
(
b3
,
b2
))))))))
->
Column
PG
Bool
)
->
Column
Sql
Bool
)
->
Select
(
fieldsL
,
(
b40
,
(
b39
,
(
b41
,
(
b42
,
(
b38
,
(
b37
,
(
b43
,
b44
))))))))
leftJoin9
q1
q2
q3
q4
q5
q6
q7
q8
q9
...
...
src/Gargantext/Database/Query/Table/Ngrams.hs
View file @
07e34aa5
...
...
@@ -52,7 +52,7 @@ selectNgramsByDoc lIds dId nt = runOpaQuery (query lIds dId nt)
query
cIds'
dId'
nt'
=
proc
()
->
do
(
ng
,
nnng
)
<-
join
-<
()
restrict
-<
foldl
(
\
b
cId
->
((
toNullable
$
pgNodeId
cId
)
.==
nnng
^.
nnng_node1_id
)
.||
b
)
(
pg
Bool
True
)
cIds'
restrict
-<
foldl
(
\
b
cId
->
((
toNullable
$
pgNodeId
cId
)
.==
nnng
^.
nnng_node1_id
)
.||
b
)
(
sql
Bool
True
)
cIds'
restrict
-<
(
toNullable
$
pgNodeId
dId'
)
.==
nnng
^.
nnng_node2_id
restrict
-<
(
toNullable
$
pgNgramsType
nt'
)
.==
nnng
^.
nnng_ngramsType
returnA
-<
ng
^.
ngrams_terms
...
...
src/Gargantext/Database/Query/Table/Node.hs
View file @
07e34aa5
...
...
@@ -43,16 +43,16 @@ import Gargantext.Database.Schema.Node
import
Gargantext.Prelude
hiding
(
sum
,
head
)
queryNodeSearchTable
::
Query
NodeSearchRead
queryNodeSearchTable
::
Select
NodeSearchRead
queryNodeSearchTable
=
selectTable
nodeTableSearch
selectNode
::
Column
PGInt4
->
Query
NodeRead
selectNode
::
Column
SqlInt4
->
Select
NodeRead
selectNode
id'
=
proc
()
->
do
row
<-
queryNodeTable
-<
()
restrict
-<
_node_id
row
.==
id'
returnA
-<
row
runGetNodes
::
Query
NodeRead
->
Cmd
err
[
Node
HyperdataAny
]
runGetNodes
::
Select
NodeRead
->
Cmd
err
[
Node
HyperdataAny
]
runGetNodes
=
runOpaQuery
------------------------------------------------------------------------
...
...
@@ -61,7 +61,7 @@ runGetNodes = runOpaQuery
-- Favorites (Bool), node_ngrams
selectNodesWith
::
HasDBid
NodeType
=>
ParentId
->
Maybe
NodeType
->
Maybe
Offset
->
Maybe
Limit
->
Query
NodeRead
->
Maybe
Offset
->
Maybe
Limit
->
Select
NodeRead
selectNodesWith
parentId
maybeNodeType
maybeOffset
maybeLimit
=
--offset' maybeOffset $ limit' maybeLimit $ orderBy (asc (hyperdataDocument_Publication_date . node_hyperdata)) $ selectNodesWith' parentId typeId
limit'
maybeLimit
$
offset'
maybeOffset
...
...
@@ -69,7 +69,7 @@ selectNodesWith parentId maybeNodeType maybeOffset maybeLimit =
$
selectNodesWith'
parentId
maybeNodeType
selectNodesWith'
::
HasDBid
NodeType
=>
ParentId
->
Maybe
NodeType
->
Query
NodeRead
=>
ParentId
->
Maybe
NodeType
->
Select
NodeRead
selectNodesWith'
parentId
maybeNodeType
=
proc
()
->
do
node'
<-
(
proc
()
->
do
row
@
(
Node
_
_
typeId
_
parentId'
_
_
_
)
<-
queryNodeTable
-<
()
...
...
@@ -79,7 +79,7 @@ selectNodesWith' parentId maybeNodeType = proc () -> do
restrict
-<
if
typeId'
>
0
then
typeId
.==
(
sqlInt4
(
typeId'
::
Int
))
else
(
pg
Bool
True
)
else
(
sql
Bool
True
)
returnA
-<
row
)
-<
()
returnA
-<
node'
...
...
@@ -198,7 +198,7 @@ getCorporaWithParentId :: HasDBid NodeType => NodeId -> Cmd err [Node HyperdataC
getCorporaWithParentId
n
=
runOpaQuery
$
selectNodesWith'
n
(
Just
NodeCorpus
)
------------------------------------------------------------------------
selectNodesWithParentID
::
NodeId
->
Query
NodeRead
selectNodesWithParentID
::
NodeId
->
Select
NodeRead
selectNodesWithParentID
n
=
proc
()
->
do
row
@
(
Node
_
_
_
_
parent_id
_
_
_
)
<-
queryNodeTable
-<
()
restrict
-<
parent_id
.==
(
pgNodeId
n
)
...
...
@@ -212,7 +212,7 @@ getNodesWithType :: (HasNodeError err, JSONB a, HasDBid NodeType) => NodeType ->
getNodesWithType
nt
_
=
runOpaQuery
$
selectNodesWithType
nt
where
selectNodesWithType
::
HasDBid
NodeType
=>
NodeType
->
Query
NodeRead
=>
NodeType
->
Select
NodeRead
selectNodesWithType
nt'
=
proc
()
->
do
row
@
(
Node
_
_
tn
_
_
_
_
_
)
<-
queryNodeTable
-<
()
restrict
-<
tn
.==
(
sqlInt4
$
toDBid
nt'
)
...
...
@@ -224,7 +224,7 @@ getNodesIdWithType nt = do
pure
(
map
NodeId
ns
)
selectNodesIdWithType
::
HasDBid
NodeType
=>
NodeType
->
Query
(
Column
PG
Int4
)
=>
NodeType
->
Select
(
Column
Sql
Int4
)
selectNodesIdWithType
nt
=
proc
()
->
do
row
@
(
Node
_
_
tn
_
_
_
_
_
)
<-
queryNodeTable
-<
()
restrict
-<
tn
.==
(
sqlInt4
$
toDBid
nt
)
...
...
@@ -281,7 +281,7 @@ node nodeType name hyperData parentId userId =
(
pgNodeId
<$>
parentId
)
(
sqlStrictText
name
)
Nothing
(
pg
JSONB
$
cs
$
encode
hyperData
)
(
sql
JSONB
$
cs
$
encode
hyperData
)
where
typeId
=
toDBid
nodeType
...
...
@@ -322,7 +322,7 @@ insertNodesWithParentR pid ns = insertNodesR (set node_parent_id (pgNodeId <$> p
node2table
::
HasDBid
NodeType
=>
UserId
->
Maybe
ParentId
->
Node'
->
NodeWrite
node2table
uid
pid
(
Node'
nt
txt
v
[]
)
=
Node
Nothing
Nothing
(
sqlInt4
$
toDBid
nt
)
(
sqlInt4
uid
)
(
fmap
pgNodeId
pid
)
(
sqlStrictText
txt
)
Nothing
(
pg
StrictJSONB
$
cs
$
encode
v
)
node2table
uid
pid
(
Node'
nt
txt
v
[]
)
=
Node
Nothing
Nothing
(
sqlInt4
$
toDBid
nt
)
(
sqlInt4
uid
)
(
fmap
pgNodeId
pid
)
(
sqlStrictText
txt
)
Nothing
(
sql
StrictJSONB
$
cs
$
encode
v
)
node2table
_
_
(
Node'
_
_
_
_
)
=
panic
"node2table: should not happen, Tree insert not implemented yet"
...
...
src/Gargantext/Database/Query/Table/Node/Children.hs
View file @
07e34aa5
...
...
@@ -69,7 +69,7 @@ getChildren pId _ maybeNodeType maybeOffset maybeLimit = do
selectChildren
::
HasDBid
NodeType
=>
ParentId
->
Maybe
NodeType
->
Query
NodeRead
->
Select
NodeRead
selectChildren
parentId
maybeNodeType
=
proc
()
->
do
row
@
(
Node
nId
_
typeName
_
parent_id
_
_
_
)
<-
queryNodeTable
-<
()
(
NodeNode
n1id
n2id
_
_
)
<-
queryNodeNodeTable
-<
()
...
...
src/Gargantext/Database/Query/Table/Node/Select.hs
View file @
07e34aa5
...
...
@@ -35,7 +35,7 @@ selectNodesWithUsername nt u = runOpaQuery (q u)
restrict
-<
_node_typename
n
.==
(
sqlInt4
$
toDBid
nt
)
returnA
-<
_node_id
n
join'
::
Query
(
NodeRead
,
UserReadNull
)
join'
::
Select
(
NodeRead
,
UserReadNull
)
join'
=
leftJoin
queryNodeTable
queryUserTable
on1
where
on1
(
n
,
us
)
=
_node_user_id
n
.==
user_id
us
...
...
src/Gargantext/Database/Query/Table/Node/UpdateOpaleye.hs
View file @
07e34aa5
...
...
@@ -37,7 +37,7 @@ updateHyperdataQuery i h = Update
,
uWhere
=
(
\
row
->
_node_id
row
.==
pgNodeId
i
)
,
uReturning
=
rCount
}
where
h'
=
(
pg
JSONB
$
cs
$
encode
$
h
)
where
h'
=
(
sql
JSONB
$
cs
$
encode
$
h
)
----------------------------------------------------------------------------------
updateNodesWithType
::
(
HasNodeError
err
...
...
src/Gargantext/Database/Query/Table/NodeNode.hs
View file @
07e34aa5
{-|
Module : Gargantext.Database.
Query
.Table.NodeNode
Module : Gargantext.Database.
Select
.Table.NodeNode
Description :
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
...
...
@@ -53,7 +53,7 @@ import Gargantext.Database.Schema.Node
import
Gargantext.Prelude
queryNodeNodeTable
::
Query
NodeNodeRead
queryNodeNodeTable
::
Select
NodeNodeRead
queryNodeNodeTable
=
selectTable
nodeNodeTable
-- | not optimized (get all ngrams without filters)
...
...
@@ -65,7 +65,7 @@ _nodesNodes = runOpaQuery queryNodeNodeTable
getNodeNode
::
NodeId
->
Cmd
err
[
NodeNode
]
getNodeNode
n
=
runOpaQuery
(
selectNodeNode
$
pgNodeId
n
)
where
selectNodeNode
::
Column
PGInt4
->
Query
NodeNodeRead
selectNodeNode
::
Column
SqlInt4
->
Select
NodeNodeRead
selectNodeNode
n'
=
proc
()
->
do
ns
<-
queryNodeNodeTable
-<
()
restrict
-<
_nn_node1_id
ns
.==
n'
...
...
@@ -81,7 +81,7 @@ getNodeNodeWith pId _ maybeNodeType = runOpaQuery query
selectChildren :: ParentId
-> Maybe NodeType
->
Query
NodeRead
->
Select
NodeRead
selectChildren parentId maybeNodeType = proc () -> do
row@(Node nId typeName _ parent_id _ _ _) <- queryNodeTable -< ()
(NodeNode _ n1id n2id _ _) <- queryNodeNodeTable -< ()
...
...
@@ -104,7 +104,7 @@ insertNodeNode ns = mkCmd $ \conn -> fromIntegral <$> (runInsert_ conn
ns'
=
map
(
\
(
NodeNode
n1
n2
x
y
)
->
NodeNode
(
pgNodeId
n1
)
(
pgNodeId
n2
)
(
pg
Double
<$>
x
)
(
sql
Double
<$>
x
)
(
sqlInt4
<$>
y
)
)
ns
...
...
@@ -127,21 +127,21 @@ deleteNodeNode n1 n2 = mkCmd $ \conn ->
------------------------------------------------------------------------
-- | Favorite management
_nodeNodeCategory
::
CorpusId
->
DocId
->
Int
->
Cmd
err
[
Int
]
_nodeNodeCategory
cId
dId
c
=
map
(
\
(
PGS
.
Only
a
)
->
a
)
<$>
runPGSQuery
fav
Query
(
c
,
cId
,
dId
)
_nodeNodeCategory
cId
dId
c
=
map
(
\
(
PGS
.
Only
a
)
->
a
)
<$>
runPGSQuery
fav
Select
(
c
,
cId
,
dId
)
where
fav
Query
::
PGS
.
Query
fav
Query
=
[
sql
|
UPDATE nodes_nodes SET category = ?
fav
Select
::
PGS
.
Query
fav
Select
=
[
sql
|
UPDATE nodes_nodes SET category = ?
WHERE node1_id = ? AND node2_id = ?
RETURNING node2_id;
|]
nodeNodesCategory
::
[(
CorpusId
,
DocId
,
Int
)]
->
Cmd
err
[
Int
]
nodeNodesCategory
inputData
=
map
(
\
(
PGS
.
Only
a
)
->
a
)
<$>
runPGSQuery
cat
Query
(
PGS
.
Only
$
Values
fields
inputData
)
<$>
runPGSQuery
cat
Select
(
PGS
.
Only
$
Values
fields
inputData
)
where
fields
=
map
(
\
t
->
QualifiedIdentifier
Nothing
t
)
[
"int4"
,
"int4"
,
"int4"
]
cat
Query
::
PGS
.
Query
cat
Query
=
[
sql
|
UPDATE nodes_nodes as nn0
cat
Select
::
PGS
.
Query
cat
Select
=
[
sql
|
UPDATE nodes_nodes as nn0
SET category = nn1.category
FROM (?) as nn1(node1_id,node2_id,category)
WHERE nn0.node1_id = nn1.node1_id
...
...
@@ -152,10 +152,10 @@ nodeNodesCategory inputData = map (\(PGS.Only a) -> a)
------------------------------------------------------------------------
-- | Score management
_nodeNodeScore
::
CorpusId
->
DocId
->
Int
->
Cmd
err
[
Int
]
_nodeNodeScore
cId
dId
c
=
map
(
\
(
PGS
.
Only
a
)
->
a
)
<$>
runPGSQuery
score
Query
(
c
,
cId
,
dId
)
_nodeNodeScore
cId
dId
c
=
map
(
\
(
PGS
.
Only
a
)
->
a
)
<$>
runPGSQuery
score
Select
(
c
,
cId
,
dId
)
where
score
Query
::
PGS
.
Query
score
Query
=
[
sql
|
UPDATE nodes_nodes SET score = ?
score
Select
::
PGS
.
Query
score
Select
=
[
sql
|
UPDATE nodes_nodes SET score = ?
WHERE node1_id = ? AND node2_id = ?
RETURNING node2_id;
|]
...
...
@@ -198,7 +198,7 @@ selectDocsDates cId = map (head' "selectDocsDates" . splitOn "-")
selectDocs
::
HasDBid
NodeType
=>
CorpusId
->
Cmd
err
[
HyperdataDocument
]
selectDocs
cId
=
runOpaQuery
(
queryDocs
cId
)
queryDocs
::
HasDBid
NodeType
=>
CorpusId
->
O
.
Query
(
Column
PG
Jsonb
)
queryDocs
::
HasDBid
NodeType
=>
CorpusId
->
O
.
Select
(
Column
Sql
Jsonb
)
queryDocs
cId
=
proc
()
->
do
(
n
,
nn
)
<-
joinInCorpus
-<
()
restrict
-<
nn
^.
nn_node1_id
.==
(
toNullable
$
pgNodeId
cId
)
...
...
@@ -209,7 +209,7 @@ queryDocs cId = proc () -> do
selectDocNodes
::
HasDBid
NodeType
=>
CorpusId
->
Cmd
err
[
Node
HyperdataDocument
]
selectDocNodes
cId
=
runOpaQuery
(
queryDocNodes
cId
)
queryDocNodes
::
HasDBid
NodeType
=>
CorpusId
->
O
.
Query
NodeRead
queryDocNodes
::
HasDBid
NodeType
=>
CorpusId
->
O
.
Select
NodeRead
queryDocNodes
cId
=
proc
()
->
do
(
n
,
nn
)
<-
joinInCorpus
-<
()
restrict
-<
nn
^.
nn_node1_id
.==
(
toNullable
$
pgNodeId
cId
)
...
...
@@ -217,25 +217,25 @@ queryDocNodes cId = proc () -> do
restrict
-<
n
^.
node_typename
.==
(
sqlInt4
$
toDBid
NodeDocument
)
returnA
-<
n
joinInCorpus
::
O
.
Query
(
NodeRead
,
NodeNodeReadNull
)
joinInCorpus
::
O
.
Select
(
NodeRead
,
NodeNodeReadNull
)
joinInCorpus
=
leftJoin
queryNodeTable
queryNodeNodeTable
cond
where
cond
::
(
NodeRead
,
NodeNodeRead
)
->
Column
PG
Bool
cond
::
(
NodeRead
,
NodeNodeRead
)
->
Column
Sql
Bool
cond
(
n
,
nn
)
=
nn
^.
nn_node2_id
.==
(
view
node_id
n
)
joinOn1
::
O
.
Query
(
NodeRead
,
NodeNodeReadNull
)
joinOn1
::
O
.
Select
(
NodeRead
,
NodeNodeReadNull
)
joinOn1
=
leftJoin
queryNodeTable
queryNodeNodeTable
cond
where
cond
::
(
NodeRead
,
NodeNodeRead
)
->
Column
PG
Bool
cond
::
(
NodeRead
,
NodeNodeRead
)
->
Column
Sql
Bool
cond
(
n
,
nn
)
=
nn
^.
nn_node1_id
.==
n
^.
node_id
------------------------------------------------------------------------
selectPublicNodes
::
HasDBid
NodeType
=>
(
Hyperdata
a
,
DefaultFromField
PG
Jsonb
a
)
selectPublicNodes
::
HasDBid
NodeType
=>
(
Hyperdata
a
,
DefaultFromField
Sql
Jsonb
a
)
=>
Cmd
err
[(
Node
a
,
Maybe
Int
)]
selectPublicNodes
=
runOpaQuery
(
queryWithType
NodeFolderPublic
)
queryWithType
::
HasDBid
NodeType
=>
NodeType
->
O
.
Query
(
NodeRead
,
Column
(
Nullable
PG
Int4
))
queryWithType
::
HasDBid
NodeType
=>
NodeType
->
O
.
Select
(
NodeRead
,
Column
(
Nullable
Sql
Int4
))
queryWithType
nt
=
proc
()
->
do
(
n
,
nn
)
<-
joinOn1
-<
()
restrict
-<
n
^.
node_typename
.==
(
sqlInt4
$
toDBid
nt
)
...
...
src/Gargantext/Database/Query/Table/NodeNodeNgrams.hs
View file @
07e34aa5
...
...
@@ -41,7 +41,7 @@ insertNodeNodeNgrams = insertNodeNodeNgramsW
(
pgNodeId
n2
)
(
sqlInt4
ng
)
(
pgNgramsTypeId
nt
)
(
pg
Double
w
)
(
sql
Double
w
)
)
insertNodeNodeNgramsW
::
[
NodeNodeNgramsWrite
]
->
Cmd
err
Int
...
...
src/Gargantext/Database/Query/Table/NodeNodeNgrams2.hs
View file @
07e34aa5
...
...
@@ -37,7 +37,7 @@ insertNodeNodeNgrams2 = insertNodeNodeNgrams2W
.
map
(
\
(
NodeNodeNgrams2
n1
n2
w
)
->
NodeNodeNgrams2
(
pgNodeId
n1
)
(
sqlInt4
n2
)
(
pg
Double
w
)
(
sql
Double
w
)
)
insertNodeNodeNgrams2W
::
[
NodeNodeNgrams2Write
]
->
Cmd
err
Int
...
...
src/Gargantext/Database/Query/Table/Node_NodeNgramsNodeNgrams.hs
View file @
07e34aa5
...
...
@@ -58,7 +58,7 @@ insert_Node_NodeNgrams_NodeNgrams = insert_Node_NodeNgrams_NodeNgrams_W
Node_NodeNgrams_NodeNgrams
(
pgNodeId
n
)
(
sqlInt4
<$>
ng1
)
(
sqlInt4
ng2
)
(
pg
Double
<$>
maybeWeight
)
(
sql
Double
<$>
maybeWeight
)
)
insert_Node_NodeNgrams_NodeNgrams_W
::
[
Node_NodeNgrams_NodeNgrams_Write
]
->
Cmd
err
Int64
...
...
src/Gargantext/Database/Query/Table/User.hs
View file @
07e34aa5
...
...
@@ -84,18 +84,18 @@ updateUserDB us = mkCmd $ \c -> runUpdate_ c (updateUserQuery us)
toUserWrite
::
NewUser
HashPassword
->
UserWrite
toUserWrite
(
NewUser
u
m
(
Auth
.
PasswordHash
p
))
=
UserDB
(
Nothing
)
(
sqlStrictText
p
)
(
Nothing
)
(
pg
Bool
True
)
(
sqlStrictText
u
)
(
Nothing
)
(
sql
Bool
True
)
(
sqlStrictText
u
)
(
sqlStrictText
"first_name"
)
(
sqlStrictText
"last_name"
)
(
sqlStrictText
m
)
(
pg
Bool
True
)
(
pg
Bool
True
)
Nothing
(
sql
Bool
True
)
(
sql
Bool
True
)
Nothing
------------------------------------------------------------------
getUsersWith
::
Username
->
Cmd
err
[
UserLight
]
getUsersWith
u
=
map
toUserLight
<$>
runOpaQuery
(
selectUsersLightWith
u
)
selectUsersLightWith
::
Username
->
Query
UserRead
selectUsersLightWith
::
Username
->
Select
UserRead
selectUsersLightWith
u
=
proc
()
->
do
row
<-
queryUserTable
-<
()
restrict
-<
user_username
row
.==
sqlStrictText
u
...
...
@@ -105,14 +105,14 @@ selectUsersLightWith u = proc () -> do
getUsersWithId
::
Int
->
Cmd
err
[
UserLight
]
getUsersWithId
i
=
map
toUserLight
<$>
runOpaQuery
(
selectUsersLightWithId
i
)
where
selectUsersLightWithId
::
Int
->
Query
UserRead
selectUsersLightWithId
::
Int
->
Select
UserRead
selectUsersLightWithId
i'
=
proc
()
->
do
row
<-
queryUserTable
-<
()
restrict
-<
user_id
row
.==
sqlInt4
i'
returnA
-<
row
queryUserTable
::
Query
UserRead
queryUserTable
::
Select
UserRead
queryUserTable
=
selectTable
userTable
----------------------------------------------------------------------
...
...
@@ -120,7 +120,7 @@ getUserHyperdata :: Int -> Cmd err [HyperdataUser]
getUserHyperdata
i
=
do
runOpaQuery
(
selectUserHyperdataWithId
i
)
where
selectUserHyperdataWithId
::
Int
->
Query
(
Column
PG
Jsonb
)
selectUserHyperdataWithId
::
Int
->
Select
(
Column
Sql
Jsonb
)
selectUserHyperdataWithId
i'
=
proc
()
->
do
row
<-
queryNodeTable
-<
()
restrict
-<
row
^.
node_id
.==
(
sqlInt4
i'
)
...
...
@@ -166,5 +166,5 @@ insertNewUsers newUsers = do
insertUsers
$
map
toUserWrite
users'
----------------------------------------------------------------------
instance
DefaultFromField
PG
Timestamptz
(
Maybe
UTCTime
)
where
defaultFromField
=
f
ieldQueryRunnerColumn
instance
DefaultFromField
Sql
Timestamptz
(
Maybe
UTCTime
)
where
defaultFromField
=
f
romPGSFromField
src/Gargantext/Database/Query/Tree/Root.hs
View file @
07e34aa5
...
...
@@ -30,7 +30,7 @@ import Gargantext.Database.Query.Table.User (queryUserTable, UserPoly(..))
import
Gargantext.Database.Schema.Node
(
NodePoly
(
..
),
NodeRead
)
import
Gargantext.Database.Schema.Node
(
queryNodeTable
)
import
Gargantext.Prelude
import
Opaleye
(
restrict
,
(
.==
),
Query
)
import
Opaleye
(
restrict
,
(
.==
),
Select
)
import
Opaleye.SqlTypes
(
sqlStrictText
,
sqlInt4
)
...
...
@@ -115,7 +115,7 @@ mkRoot user = do
_
->
pure
rs
pure
rs
selectRoot
::
User
->
Query
NodeRead
selectRoot
::
User
->
Select
NodeRead
selectRoot
(
UserName
username
)
=
proc
()
->
do
row
<-
queryNodeTable
-<
()
users
<-
queryUserTable
-<
()
...
...
src/Gargantext/Database/Schema/Ngrams.hs
View file @
07e34aa5
...
...
@@ -46,17 +46,17 @@ data NgramsPoly id terms n = NgramsDB { _ngrams_id :: !id
,
_ngrams_n
::
!
n
}
deriving
(
Show
)
type
NgramsWrite
=
NgramsPoly
(
Maybe
(
Column
PG
Int4
))
(
Column
PG
Text
)
(
Column
PG
Int4
)
type
NgramsWrite
=
NgramsPoly
(
Maybe
(
Column
Sql
Int4
))
(
Column
Sql
Text
)
(
Column
Sql
Int4
)
type
NgramsRead
=
NgramsPoly
(
Column
PG
Int4
)
(
Column
PG
Text
)
(
Column
PG
Int4
)
type
NgramsRead
=
NgramsPoly
(
Column
Sql
Int4
)
(
Column
Sql
Text
)
(
Column
Sql
Int4
)
type
NgramsReadNull
=
NgramsPoly
(
Column
(
Nullable
PG
Int4
))
(
Column
(
Nullable
PG
Text
))
(
Column
(
Nullable
PG
Int4
))
type
NgramsReadNull
=
NgramsPoly
(
Column
(
Nullable
Sql
Int4
))
(
Column
(
Nullable
Sql
Text
))
(
Column
(
Nullable
Sql
Int4
))
type
NgramsDB
=
NgramsPoly
Int
Text
Int
...
...
@@ -119,14 +119,14 @@ instance ToParamSchema NgramsType where
toParamSchema
_
=
toParamSchema
(
Proxy
::
Proxy
TODO
)
instance
DefaultFromField
(
Nullable
PG
Int4
)
NgramsTypeId
instance
DefaultFromField
(
Nullable
Sql
Int4
)
NgramsTypeId
where
defaultFromField
=
f
ieldQueryRunnerColumn
defaultFromField
=
f
romPGSFromField
pgNgramsType
::
NgramsType
->
Column
PG
Int4
pgNgramsType
::
NgramsType
->
Column
Sql
Int4
pgNgramsType
=
pgNgramsTypeId
.
ngramsTypeId
pgNgramsTypeId
::
NgramsTypeId
->
Column
PG
Int4
pgNgramsTypeId
::
NgramsTypeId
->
Column
Sql
Int4
pgNgramsTypeId
(
NgramsTypeId
n
)
=
sqlInt4
n
ngramsTypeId
::
NgramsType
->
NgramsTypeId
...
...
src/Gargantext/Database/Schema/NgramsPostag.hs
View file @
07e34aa5
...
...
@@ -51,29 +51,29 @@ data PosTag = PosTag { unPosTag :: !Text }
type
NgramsPostagDB
=
NgramsPostagPoly
(
Maybe
Int
)
Int
Int
(
Maybe
Text
)
Int
Int
Int
------------------------------------------------------------------------
type
NgramsPosTagWrite
=
NgramsPostagPoly
(
Maybe
(
Column
PG
Int4
))
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Maybe
(
Column
PG
Text
))
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Maybe
(
Column
PG
Int4
))
type
NgramsPosTagWrite
=
NgramsPostagPoly
(
Maybe
(
Column
Sql
Int4
))
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Maybe
(
Column
Sql
Text
))
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Maybe
(
Column
Sql
Int4
))
type
NgramsPosTagRead
=
NgramsPostagPoly
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Column
PG
Text
)
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Column
PG
Int4
)
type
NgramsPosTagRead
=
NgramsPostagPoly
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Column
Sql
Text
)
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
type
NgramsPosTagReadNull
=
NgramsPostagPoly
(
Column
(
Nullable
PG
Int4
))
(
Column
(
Nullable
PG
Int4
))
(
Column
(
Nullable
PG
Int4
))
(
Column
(
Nullable
PG
Text
))
(
Column
(
Nullable
PG
Int4
))
(
Column
(
Nullable
PG
Int4
))
(
Column
(
Nullable
PG
Int4
))
type
NgramsPosTagReadNull
=
NgramsPostagPoly
(
Column
(
Nullable
Sql
Int4
))
(
Column
(
Nullable
Sql
Int4
))
(
Column
(
Nullable
Sql
Int4
))
(
Column
(
Nullable
Sql
Text
))
(
Column
(
Nullable
Sql
Int4
))
(
Column
(
Nullable
Sql
Int4
))
(
Column
(
Nullable
Sql
Int4
))
makeLenses
''
N
gramsPostagPoly
instance
PGS
.
ToRow
NgramsPostagDB
where
...
...
src/Gargantext/Database/Schema/Node.hs
View file @
07e34aa5
...
...
@@ -72,68 +72,68 @@ nodeTable = Table "nodes" (pNode Node { _node_id = optionalTableField "i
queryNodeTable
::
Query
NodeRead
queryNodeTable
=
selectTable
nodeTable
------------------------------------------------------------------------
type
NodeWrite
=
NodePoly
(
Maybe
(
Column
PG
Int4
)
)
(
Maybe
(
Column
PG
Text
)
)
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Maybe
(
Column
PG
Int4
)
)
(
Column
PG
Text
)
(
Maybe
(
Column
PG
Timestamptz
))
(
Column
PG
Jsonb
)
type
NodeRead
=
NodePoly
(
Column
PG
Int4
)
(
Column
PG
Text
)
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Column
PG
Text
)
(
Column
PG
Timestamptz
)
(
Column
PG
Jsonb
)
type
NodeReadNull
=
NodePoly
(
Column
(
Nullable
PG
Int4
))
(
Column
(
Nullable
PG
Text
))
(
Column
(
Nullable
PG
Int4
))
(
Column
(
Nullable
PG
Int4
))
(
Column
(
Nullable
PG
Int4
))
(
Column
(
Nullable
PG
Text
))
(
Column
(
Nullable
PG
Timestamptz
))
(
Column
(
Nullable
PG
Jsonb
))
type
NodeWrite
=
NodePoly
(
Maybe
(
Column
Sql
Int4
)
)
(
Maybe
(
Column
Sql
Text
)
)
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Maybe
(
Column
Sql
Int4
)
)
(
Column
Sql
Text
)
(
Maybe
(
Column
Sql
Timestamptz
))
(
Column
Sql
Jsonb
)
type
NodeRead
=
NodePoly
(
Column
Sql
Int4
)
(
Column
Sql
Text
)
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Column
Sql
Text
)
(
Column
Sql
Timestamptz
)
(
Column
Sql
Jsonb
)
type
NodeReadNull
=
NodePoly
(
Column
(
Nullable
Sql
Int4
))
(
Column
(
Nullable
Sql
Text
))
(
Column
(
Nullable
Sql
Int4
))
(
Column
(
Nullable
Sql
Int4
))
(
Column
(
Nullable
Sql
Int4
))
(
Column
(
Nullable
Sql
Text
))
(
Column
(
Nullable
Sql
Timestamptz
))
(
Column
(
Nullable
Sql
Jsonb
))
------------------------------------------------------------------------
-- | Node(Read|Write)Search is slower than Node(Write|Read) use it
-- for full text search only
type
NodeSearchWrite
=
NodePolySearch
(
Maybe
(
Column
PG
Int4
)
)
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Column
(
Nullable
PG
Int4
)
)
(
Column
PG
Text
)
(
Maybe
(
Column
PG
Timestamptz
))
(
Column
PG
Jsonb
)
(
Maybe
(
Column
PG
TSVector
)
)
(
Maybe
(
Column
Sql
Int4
)
)
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Column
(
Nullable
Sql
Int4
)
)
(
Column
Sql
Text
)
(
Maybe
(
Column
Sql
Timestamptz
))
(
Column
Sql
Jsonb
)
(
Maybe
(
Column
Sql
TSVector
)
)
type
NodeSearchRead
=
NodePolySearch
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Column
(
Nullable
PG
Int4
))
(
Column
PG
Text
)
(
Column
PG
Timestamptz
)
(
Column
PG
Jsonb
)
(
Column
PG
TSVector
)
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Column
(
Nullable
Sql
Int4
))
(
Column
Sql
Text
)
(
Column
Sql
Timestamptz
)
(
Column
Sql
Jsonb
)
(
Column
Sql
TSVector
)
type
NodeSearchReadNull
=
NodePolySearch
(
Column
(
Nullable
PG
Int4
)
)
(
Column
(
Nullable
PG
Int4
)
)
(
Column
(
Nullable
PG
Int4
)
)
(
Column
(
Nullable
PG
Int4
)
)
(
Column
(
Nullable
PG
Text
)
)
(
Column
(
Nullable
PG
Timestamptz
))
(
Column
(
Nullable
PG
Jsonb
)
)
(
Column
(
Nullable
PG
TSVector
)
)
(
Column
(
Nullable
Sql
Int4
)
)
(
Column
(
Nullable
Sql
Int4
)
)
(
Column
(
Nullable
Sql
Int4
)
)
(
Column
(
Nullable
Sql
Int4
)
)
(
Column
(
Nullable
Sql
Text
)
)
(
Column
(
Nullable
Sql
Timestamptz
))
(
Column
(
Nullable
Sql
Jsonb
)
)
(
Column
(
Nullable
Sql
TSVector
)
)
data
NodePolySearch
id
...
...
src/Gargantext/Database/Schema/NodeNgrams.hs
View file @
07e34aa5
...
...
@@ -47,36 +47,36 @@ data NodeNgramsPoly id
}
deriving
(
Show
,
Eq
,
Ord
)
{-
type NodeNgramsWrite = NodeNgramsPoly (Maybe (Column (
PG
Int4)))
(Column (
PG
Int4))
(Maybe (Column (
PG
Int4)))
(Column (
PG
Int4))
(Maybe (Column (
PG
Int4)))
(Maybe (Column (
PG
Int4)))
(Maybe (Column (
PG
Int4)))
(Maybe (Column (
PG
Int4)))
(Maybe (Column (
PG
Float8)))
type NodeNgramsWrite = NodeNgramsPoly (Maybe (Column (
Sql
Int4)))
(Column (
Sql
Int4))
(Maybe (Column (
Sql
Int4)))
(Column (
Sql
Int4))
(Maybe (Column (
Sql
Int4)))
(Maybe (Column (
Sql
Int4)))
(Maybe (Column (
Sql
Int4)))
(Maybe (Column (
Sql
Int4)))
(Maybe (Column (
Sql
Float8)))
type NodeNodeRead = NodeNgramsPoly (Column
PG
Int4)
(Column
PG
Int4)
(Column
PG
Int4)
(Column
PG
Int4)
(Column
PG
Int4)
(Column
PG
Int4)
(Column
PG
Int4)
(Column
PG
Int4)
(Column
PG
Float8)
type NodeNodeRead = NodeNgramsPoly (Column
Sql
Int4)
(Column
Sql
Int4)
(Column
Sql
Int4)
(Column
Sql
Int4)
(Column
Sql
Int4)
(Column
Sql
Int4)
(Column
Sql
Int4)
(Column
Sql
Int4)
(Column
Sql
Float8)
type NodeNgramsReadNull = NodeNgramsPoly (Column (Nullable
PG
Int4))
(Column (Nullable
PG
Int4))
(Column (Nullable
PG
Int4))
(Column (Nullable
PG
Int4))
type NodeNgramsReadNull = NodeNgramsPoly (Column (Nullable
Sql
Int4))
(Column (Nullable
Sql
Int4))
(Column (Nullable
Sql
Int4))
(Column (Nullable
Sql
Int4))
(Column (Nullable
PG
Int4))
(Column (Nullable
PG
Int4))
(Column (Nullable
PG
Int4))
(Column (Nullable
PG
Int4))
(Column (Nullable
PG
Float8))
(Column (Nullable
Sql
Int4))
(Column (Nullable
Sql
Int4))
(Column (Nullable
Sql
Int4))
(Column (Nullable
Sql
Int4))
(Column (Nullable
Sql
Float8))
-}
type
NodeNgramsId
=
Int
type
NgramsId
=
Int
...
...
src/Gargantext/Database/Schema/NodeNode.hs
View file @
07e34aa5
...
...
@@ -32,20 +32,20 @@ data NodeNodePoly node1_id node2_id score cat
,
_nn_category
::
!
cat
}
deriving
(
Show
)
type
NodeNodeWrite
=
NodeNodePoly
(
Column
(
PG
Int4
))
(
Column
(
PG
Int4
))
(
Maybe
(
Column
(
PG
Float8
)))
(
Maybe
(
Column
(
PG
Int4
)))
type
NodeNodeWrite
=
NodeNodePoly
(
Column
(
Sql
Int4
))
(
Column
(
Sql
Int4
))
(
Maybe
(
Column
(
Sql
Float8
)))
(
Maybe
(
Column
(
Sql
Int4
)))
type
NodeNodeRead
=
NodeNodePoly
(
Column
(
PG
Int4
))
(
Column
(
PG
Int4
))
(
Column
(
PG
Float8
))
(
Column
(
PG
Int4
))
type
NodeNodeRead
=
NodeNodePoly
(
Column
(
Sql
Int4
))
(
Column
(
Sql
Int4
))
(
Column
(
Sql
Float8
))
(
Column
(
Sql
Int4
))
type
NodeNodeReadNull
=
NodeNodePoly
(
Column
(
Nullable
PG
Int4
))
(
Column
(
Nullable
PG
Int4
))
(
Column
(
Nullable
PG
Float8
))
(
Column
(
Nullable
PG
Int4
))
type
NodeNodeReadNull
=
NodeNodePoly
(
Column
(
Nullable
Sql
Int4
))
(
Column
(
Nullable
Sql
Int4
))
(
Column
(
Nullable
Sql
Float8
))
(
Column
(
Nullable
Sql
Int4
))
type
NodeNode
=
NodeNodePoly
NodeId
NodeId
(
Maybe
Double
)
(
Maybe
Int
)
...
...
@@ -63,18 +63,18 @@ nodeNodeTable =
}
)
instance
DefaultFromField
(
Nullable
PG
Int4
)
Int
where
defaultFromField
=
f
ieldQueryRunnerColumn
instance
DefaultFromField
(
Nullable
Sql
Int4
)
Int
where
defaultFromField
=
f
romPGSFromField
instance
DefaultFromField
(
Nullable
PG
Float8
)
Int
where
defaultFromField
=
f
ieldQueryRunnerColumn
instance
DefaultFromField
(
Nullable
Sql
Float8
)
Int
where
defaultFromField
=
f
romPGSFromField
instance
DefaultFromField
(
Nullable
PG
Float8
)
Double
where
defaultFromField
=
f
ieldQueryRunnerColumn
instance
DefaultFromField
(
Nullable
Sql
Float8
)
Double
where
defaultFromField
=
f
romPGSFromField
instance
DefaultFromField
PG
Float8
(
Maybe
Double
)
where
defaultFromField
=
f
ieldQueryRunnerColumn
instance
DefaultFromField
Sql
Float8
(
Maybe
Double
)
where
defaultFromField
=
f
romPGSFromField
instance
DefaultFromField
PG
Int4
(
Maybe
Int
)
where
defaultFromField
=
f
ieldQueryRunnerColumn
instance
DefaultFromField
Sql
Int4
(
Maybe
Int
)
where
defaultFromField
=
f
romPGSFromField
src/Gargantext/Database/Schema/NodeNodeNgrams.hs
View file @
07e34aa5
...
...
@@ -32,25 +32,25 @@ data NodeNodeNgramsPoly n1 n2 ngrams_id ngt w
}
deriving
(
Show
)
type
NodeNodeNgramsWrite
=
NodeNodeNgramsPoly
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Column
PG
Float8
)
NodeNodeNgramsPoly
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Column
Sql
Float8
)
type
NodeNodeNgramsRead
=
NodeNodeNgramsPoly
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Column
PG
Float8
)
NodeNodeNgramsPoly
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Column
Sql
Float8
)
type
NodeNodeNgramsReadNull
=
NodeNodeNgramsPoly
(
Column
(
Nullable
PG
Int4
))
(
Column
(
Nullable
PG
Int4
))
(
Column
(
Nullable
PG
Int4
))
(
Column
(
Nullable
PG
Int4
))
(
Column
(
Nullable
PG
Float8
))
NodeNodeNgramsPoly
(
Column
(
Nullable
Sql
Int4
))
(
Column
(
Nullable
Sql
Int4
))
(
Column
(
Nullable
Sql
Int4
))
(
Column
(
Nullable
Sql
Int4
))
(
Column
(
Nullable
Sql
Float8
))
type
NodeNodeNgrams
=
NodeNodeNgramsPoly
CorpusId
DocId
NgramsId
NgramsTypeId
Double
...
...
src/Gargantext/Database/Schema/NodeNodeNgrams2.hs
View file @
07e34aa5
...
...
@@ -30,19 +30,19 @@ data NodeNodeNgrams2Poly node_id nodengrams_id w
}
deriving
(
Show
)
type
NodeNodeNgrams2Write
=
NodeNodeNgrams2Poly
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Column
PG
Float8
)
NodeNodeNgrams2Poly
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Column
Sql
Float8
)
type
NodeNodeNgrams2Read
=
NodeNodeNgrams2Poly
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Column
PG
Float8
)
NodeNodeNgrams2Poly
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Column
Sql
Float8
)
type
NodeNodeNgrams2ReadNull
=
NodeNodeNgrams2Poly
(
Column
(
Nullable
PG
Int4
))
(
Column
(
Nullable
PG
Int4
))
(
Column
(
Nullable
PG
Float8
))
NodeNodeNgrams2Poly
(
Column
(
Nullable
Sql
Int4
))
(
Column
(
Nullable
Sql
Int4
))
(
Column
(
Nullable
Sql
Float8
))
type
NodeNodeNgrams2
=
NodeNodeNgrams2Poly
DocId
NodeNgramsId
Double
...
...
src/Gargantext/Database/Schema/Node_NodeNgramsNodeNgrams.hs
View file @
07e34aa5
...
...
@@ -45,17 +45,17 @@ data Node_NodeNgrams_NodeNgrams_Poly node_id nng1_id nng2_id weight =
type
Node_NodeNgrams_NodeNgrams_Write
=
Node_NodeNgrams_NodeNgrams_Poly
(
Column
PG
Int4
)
(
Maybe
(
Column
PG
Int4
))
(
Column
PG
Int4
)
(
Maybe
(
Column
PG
Float8
))
(
Column
Sql
Int4
)
(
Maybe
(
Column
Sql
Int4
))
(
Column
Sql
Int4
)
(
Maybe
(
Column
Sql
Float8
))
type
Node_NodeNgrams_NodeNgrams_Read
=
Node_NodeNgrams_NodeNgrams_Poly
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Column
PG
Int4
)
(
Column
PG
Float8
)
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Column
Sql
Int4
)
(
Column
Sql
Float8
)
type
ListNgramsId
=
Int
...
...
@@ -79,9 +79,9 @@ node_NodeNgrams_NodeNgrams_Table =
}
)
instance
DefaultFromField
PG
Int4
(
Maybe
Int
)
where
defaultFromField
=
f
ieldQueryRunnerColumn
instance
DefaultFromField
Sql
Int4
(
Maybe
Int
)
where
defaultFromField
=
f
romPGSFromField
instance
DefaultFromField
PG
Float8
(
Maybe
Double
)
where
defaultFromField
=
f
ieldQueryRunnerColumn
instance
DefaultFromField
Sql
Float8
(
Maybe
Double
)
where
defaultFromField
=
f
romPGSFromField
src/Gargantext/Database/Schema/NodesNgramsRepo.hs
View file @
07e34aa5
...
...
@@ -37,21 +37,21 @@ data RepoDbPoly version patches
} deriving (Show)
type RepoDbWrite
= RepoDbPoly (Column
PG
Int4)
(Column
PG
Jsonb)
= RepoDbPoly (Column
Sql
Int4)
(Column
Sql
Jsonb)
type RepoDbRead
= RepoDbPoly (Column
PG
Int4)
(Column
PG
Jsonb)
= RepoDbPoly (Column
Sql
Int4)
(Column
Sql
Jsonb)
type RepoDbNgrams = RepoDbPoly Int NgramsStatePatch
$(makeAdaptorAndInstance "pRepoDbNgrams" ''RepoDbPoly)
makeLenses ''RepoDbPoly
instance DefaultFromField
PG
Jsonb
instance DefaultFromField
Sql
Jsonb
(PatchMap NgramsType
(PatchMap NodeId NgramsTablePatch))
where
defaultFromField = f
ieldQueryRunnerColumn
defaultFromField = f
romPGSFromField
repoTable :: Table RepoDbWrite RepoDbRead
repoTable = Table "nodes_ngrams_repo"
...
...
src/Gargantext/Database/Schema/Prelude.hs
View file @
07e34aa5
...
...
@@ -25,6 +25,7 @@ module Gargantext.Database.Schema.Prelude
,
module
GHC
.
Generics
,
module
Gargantext
.
Core
.
Utils
.
Prefix
,
module
Opaleye
,
module
Opaleye
.
Internal
.
Table
,
module
Opaleye
.
Internal
.
QueryArr
,
module
Test
.
QuickCheck
.
Arbitrary
)
...
...
@@ -37,8 +38,9 @@ import Data.Profunctor.Product.TH (makeAdaptorAndInstance)
import
Data.Swagger
hiding
(
required
,
in_
)
import
GHC.Generics
(
Generic
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
)
import
Opaleye
hiding
(
FromField
,
readOnly
)
import
Opaleye
hiding
(
FromField
)
import
Opaleye.Internal.QueryArr
(
Query
)
import
Opaleye.Internal.Table
(
Table
(
..
))
import
Test.QuickCheck.Arbitrary
hiding
(
vector
)
import
Database.PostgreSQL.Simple.FromField
(
FromField
,
fromField
)
...
...
src/Gargantext/Database/Schema/User.hs
View file @
07e34aa5
...
...
@@ -38,7 +38,7 @@ import Data.Aeson.TH (deriveJSON)
import
Control.Lens.TH
(
makeLensesWith
,
abbreviatedFields
)
import
Data.Profunctor.Product.TH
(
makeAdaptorAndInstance
)
import
Opaleye
hiding
(
FromField
)
import
Opaleye.Internal.Table
(
Table
(
..
))
------------------------------------------------------------------------
data
UserLight
=
UserLight
{
userLight_id
::
!
Int
,
userLight_username
::
!
Text
...
...
@@ -72,26 +72,26 @@ data UserPoly id pass llogin suser
}
deriving
(
Show
,
Generic
)
type
UserWrite
=
UserPoly
(
Maybe
(
Column
PGInt4
))
(
Column
PG
Text
)
(
Maybe
(
Column
PGTimestamptz
))
(
Column
PG
Bool
)
(
Column
PGText
)
(
Column
PG
Text
)
(
Column
PGText
)
(
Column
PG
Text
)
(
Column
PGBool
)
(
Column
PG
Bool
)
(
Maybe
(
Column
PG
Timestamptz
))
type
UserRead
=
UserPoly
(
Column
PGInt4
)
(
Column
PG
Text
)
(
Column
PGTimestamptz
)
(
Column
PG
Bool
)
(
Column
PGText
)
(
Column
PG
Text
)
(
Column
PGText
)
(
Column
PG
Text
)
(
Column
PGBool
)
(
Column
PG
Bool
)
(
Column
PG
Timestamptz
)
type
UserReadNull
=
UserPoly
(
Column
(
Nullable
PGInt4
))
(
Column
(
Nullable
PG
Text
))
(
Column
(
Nullable
PGTimestamptz
))
(
Column
(
Nullable
PG
Bool
))
(
Column
(
Nullable
PGText
))
(
Column
(
Nullable
PG
Text
))
(
Column
(
Nullable
PGText
))
(
Column
(
Nullable
PG
Text
))
(
Column
(
Nullable
PGBool
))
(
Column
(
Nullable
PG
Bool
))
(
Column
(
Nullable
PG
Timestamptz
))
type
UserWrite
=
UserPoly
(
Maybe
(
Column
SqlInt4
))
(
Column
Sql
Text
)
(
Maybe
(
Column
SqlTimestamptz
))
(
Column
Sql
Bool
)
(
Column
SqlText
)
(
Column
Sql
Text
)
(
Column
SqlText
)
(
Column
Sql
Text
)
(
Column
SqlBool
)
(
Column
Sql
Bool
)
(
Maybe
(
Column
Sql
Timestamptz
))
type
UserRead
=
UserPoly
(
Column
SqlInt4
)
(
Column
Sql
Text
)
(
Column
SqlTimestamptz
)
(
Column
Sql
Bool
)
(
Column
SqlText
)
(
Column
Sql
Text
)
(
Column
SqlText
)
(
Column
Sql
Text
)
(
Column
SqlBool
)
(
Column
Sql
Bool
)
(
Column
Sql
Timestamptz
)
type
UserReadNull
=
UserPoly
(
Column
(
Nullable
SqlInt4
))
(
Column
(
Nullable
Sql
Text
))
(
Column
(
Nullable
SqlTimestamptz
))
(
Column
(
Nullable
Sql
Bool
))
(
Column
(
Nullable
SqlText
))
(
Column
(
Nullable
Sql
Text
))
(
Column
(
Nullable
SqlText
))
(
Column
(
Nullable
Sql
Text
))
(
Column
(
Nullable
SqlBool
))
(
Column
(
Nullable
Sql
Bool
))
(
Column
(
Nullable
Sql
Timestamptz
))
type
UserDB
=
UserPoly
Int
Text
(
Maybe
UTCTime
)
Bool
Text
Text
Text
Text
Bool
Bool
UTCTime
...
...
stack.yaml
View file @
07e34aa5
...
...
@@ -6,9 +6,7 @@ skip-ghc-check: true
packages
:
-
.
#- 'deps/gargantext-graph'
#- 'deps/patches-map'
#- 'deps/accelerate'
#- 'deps/accelerate-utility'
#- 'deps/haskell-opaleye'
docker
:
enable
:
false
...
...
@@ -63,7 +61,7 @@ extra-deps:
# Databases libs
-
git
:
https://github.com/delanoe/haskell-opaleye.git
commit
:
d3ab7acd5ede737478763630035aa880f7e34444
commit
:
756cb90f4ce725463d957bc899d764e0ed73738c
-
git
:
https://github.com/delanoe/hsparql.git
commit
:
2acbbc55ac9bbd4bf1a713c586b8b8e8b82892eb
-
git
:
https://github.com/robstewart57/rdf4h.git
...
...
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