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
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
Christian Merten
haskell-gargantext
Commits
548c8d15
Commit
548c8d15
authored
Mar 18, 2022
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-pairing' into dev
parents
563912df
254e5d36
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
374 additions
and
219 deletions
+374
-219
schema.sql
devops/postgres/schema.sql
+15
-5
0.0.5.7.5.sql
devops/postgres/upgrade/0.0.5.7.5.sql
+14
-0
Client.hs
src/Gargantext/API/Client.hs
+3
-3
Tools.hs
src/Gargantext/API/Ngrams/Tools.hs
+3
-3
Node.hs
src/Gargantext/API/Node.hs
+1
-1
Export.hs
src/Gargantext/API/Node/Corpus/Export.hs
+1
-1
Chart.hs
src/Gargantext/Core/Viz/Chart.hs
+2
-2
API.hs
src/Gargantext/Core/Viz/Graph/API.hs
+1
-1
Pairing.hs
src/Gargantext/Database/Action/Flow/Pairing.hs
+105
-95
Metrics.hs
src/Gargantext/Database/Action/Metrics.hs
+2
-1
NgramsByContext.hs
src/Gargantext/Database/Action/Metrics/NgramsByContext.hs
+1
-1
Search.hs
src/Gargantext/Database/Action/Search.hs
+53
-55
Node.hs
src/Gargantext/Database/Admin/Types/Node.hs
+12
-9
Context.hs
src/Gargantext/Database/Query/Table/Context.hs
+2
-4
Children.hs
src/Gargantext/Database/Query/Table/Node/Children.hs
+4
-4
NodeContext.hs
src/Gargantext/Database/Query/Table/NodeContext.hs
+4
-3
NodeContext_NodeContext.hs
...argantext/Database/Query/Table/NodeContext_NodeContext.hs
+57
-0
NodeContext.hs
src/Gargantext/Database/Schema/NodeContext.hs
+19
-14
NodeContext_NodeContext.hs
src/Gargantext/Database/Schema/NodeContext_NodeContext.hs
+58
-0
NodeNode.hs
src/Gargantext/Database/Schema/NodeNode.hs
+0
-17
Types.hs
src/Gargantext/Database/Types.hs
+17
-0
No files found.
devops/postgres/schema.sql
View file @
548c8d15
...
@@ -135,16 +135,27 @@ CREATE TABLE public.nodes_nodes (
...
@@ -135,16 +135,27 @@ CREATE TABLE public.nodes_nodes (
ALTER
TABLE
public
.
nodes_nodes
OWNER
TO
gargantua
;
ALTER
TABLE
public
.
nodes_nodes
OWNER
TO
gargantua
;
-- To attach contexts to a Corpus
-- To attach contexts to a Corpus
CREATE
TABLE
public
.
nodes_contexts
(
CREATE
TABLE
public
.
nodes_contexts
(
id
SERIAL
,
node_id
INTEGER
NOT
NULL
REFERENCES
public
.
nodes
(
id
)
ON
DELETE
CASCADE
,
node_id
INTEGER
NOT
NULL
REFERENCES
public
.
nodes
(
id
)
ON
DELETE
CASCADE
,
context_id
INTEGER
NOT
NULL
REFERENCES
public
.
contexts
(
id
)
ON
DELETE
CASCADE
,
context_id
INTEGER
NOT
NULL
REFERENCES
public
.
contexts
(
id
)
ON
DELETE
CASCADE
,
score
REAL
,
score
REAL
,
category
INTEGER
,
category
INTEGER
,
PRIMARY
KEY
(
node_id
,
context_
id
)
PRIMARY
KEY
(
id
)
);
);
ALTER
TABLE
public
.
nodes_contexts
OWNER
TO
gargantua
;
ALTER
TABLE
public
.
nodes_contexts
OWNER
TO
gargantua
;
CREATE
TABLE
public
.
nodescontexts_nodescontexts
(
nodescontexts1
INTEGER
NOT
NULL
REFERENCES
public
.
nodes_contexts
(
id
)
ON
DELETE
CASCADE
,
nodescontexts2
INTEGER
NOT
NULL
REFERENCES
public
.
nodes_contexts
(
id
)
ON
DELETE
CASCADE
,
PRIMARY
KEY
(
nodescontexts1
,
nodescontexts2
)
);
ALTER
TABLE
public
.
nodescontexts_nodescontexts
OWNER
TO
gargantua
;
---------------------------------------------------------------
---------------------------------------------------------------
CREATE
TABLE
public
.
context_node_ngrams
(
CREATE
TABLE
public
.
context_node_ngrams
(
context_id
INTEGER
NOT
NULL
REFERENCES
public
.
contexts
(
id
)
ON
DELETE
CASCADE
,
context_id
INTEGER
NOT
NULL
REFERENCES
public
.
contexts
(
id
)
ON
DELETE
CASCADE
,
...
@@ -157,7 +168,7 @@ CREATE TABLE public.context_node_ngrams (
...
@@ -157,7 +168,7 @@ CREATE TABLE public.context_node_ngrams (
ALTER
TABLE
public
.
context_node_ngrams
OWNER
TO
gargantua
;
ALTER
TABLE
public
.
context_node_ngrams
OWNER
TO
gargantua
;
CREATE
TABLE
public
.
context_node_ngrams2
(
CREATE
TABLE
public
.
context_node_ngrams2
(
context_id
INTEGER
NOT
NULL
REFERENCES
public
.
contexts
(
id
)
ON
DELETE
CASCADE
,
context_id
INTEGER
NOT
NULL
REFERENCES
public
.
contexts
(
id
)
ON
DELETE
CASCADE
,
nodengrams_id
INTEGER
NOT
NULL
REFERENCES
public
.
node_ngrams
(
id
)
ON
DELETE
CASCADE
,
nodengrams_id
INTEGER
NOT
NULL
REFERENCES
public
.
node_ngrams
(
id
)
ON
DELETE
CASCADE
,
weight
double
precision
,
weight
double
precision
,
PRIMARY
KEY
(
context_id
,
nodengrams_id
)
PRIMARY
KEY
(
context_id
,
nodengrams_id
)
...
@@ -185,8 +196,6 @@ PRIMARY KEY (node_id, nodengrams_id)
...
@@ -185,8 +196,6 @@ PRIMARY KEY (node_id, nodengrams_id)
ALTER
TABLE
public
.
node_node_ngrams2
OWNER
TO
gargantua
;
ALTER
TABLE
public
.
node_node_ngrams2
OWNER
TO
gargantua
;
--------------------------------------------------------------
--------------------------------------------------------------
--CREATE TABLE public.nodes_ngrams_repo (
--CREATE TABLE public.nodes_ngrams_repo (
...
@@ -230,7 +239,7 @@ CREATE INDEX ON public.contexts USING btree (id, typename, date DESC);
...
@@ -230,7 +239,7 @@ CREATE INDEX ON public.contexts USING btree (id, typename, date DESC);
CREATE
INDEX
ON
public
.
contexts
USING
btree
(
typename
,
id
);
CREATE
INDEX
ON
public
.
contexts
USING
btree
(
typename
,
id
);
CREATE
UNIQUE
INDEX
ON
public
.
contexts
USING
btree
(
hash_id
);
CREATE
UNIQUE
INDEX
ON
public
.
contexts
USING
btree
(
hash_id
);
CREATE
INDEX
ON
public
.
nodescontexts_nodescontexts
USING
btree
(
nodescontexts1
,
nodescontexts2
);
-- CREATE UNIQUE INDEX ON public.nodes USING btree (((hyperdata ->> 'uniqId'::text)));
-- CREATE UNIQUE INDEX ON public.nodes USING btree (((hyperdata ->> 'uniqId'::text)));
-- CREATE UNIQUE INDEX ON public.nodes USING btree (((hyperdata ->> 'uniqIdBdd'::text)));
-- CREATE UNIQUE INDEX ON public.nodes USING btree (((hyperdata ->> 'uniqIdBdd'::text)));
-- CREATE UNIQUE INDEX ON public.nodes USING btree (typename, parent_id, ((hyperdata ->> 'uniqId'::text)));
-- CREATE UNIQUE INDEX ON public.nodes USING btree (typename, parent_id, ((hyperdata ->> 'uniqId'::text)));
...
@@ -249,6 +258,7 @@ CREATE UNIQUE INDEX ON public.node_ngrams USING btree (node_id,node_subtype, ngr
...
@@ -249,6 +258,7 @@ CREATE UNIQUE INDEX ON public.node_ngrams USING btree (node_id,node_subtype, ngr
CREATE
UNIQUE
INDEX
ON
public
.
nodes_nodes
USING
btree
(
node1_id
,
node2_id
);
CREATE
UNIQUE
INDEX
ON
public
.
nodes_nodes
USING
btree
(
node1_id
,
node2_id
);
CREATE
INDEX
ON
public
.
nodes_nodes
USING
btree
(
node1_id
,
node2_id
,
category
);
CREATE
INDEX
ON
public
.
nodes_nodes
USING
btree
(
node1_id
,
node2_id
,
category
);
-- To make the links between Corpus Node and its contexts
-- To make the links between Corpus Node and its contexts
CREATE
UNIQUE
INDEX
ON
public
.
nodes_contexts
USING
btree
(
node_id
,
context_id
);
CREATE
UNIQUE
INDEX
ON
public
.
nodes_contexts
USING
btree
(
node_id
,
context_id
);
CREATE
INDEX
ON
public
.
nodes_contexts
USING
btree
(
node_id
,
context_id
,
category
);
CREATE
INDEX
ON
public
.
nodes_contexts
USING
btree
(
node_id
,
context_id
,
category
);
...
...
devops/postgres/upgrade/0.0.5.7.5.sql
0 → 100644
View file @
548c8d15
ALTER
TABLE
nodes_contexts
DROP
CONSTRAINT
nodes_contexts_pkey
;
ALTER
TABLE
nodes_contexts
ADD
COLUMN
id
SERIAL
PRIMARY
KEY
;
CREATE
TABLE
public
.
nodescontexts_nodescontexts
(
nodescontexts1
INTEGER
NOT
NULL
REFERENCES
public
.
nodes_contexts
(
id
)
ON
DELETE
CASCADE
,
nodescontexts2
INTEGER
NOT
NULL
REFERENCES
public
.
nodes_contexts
(
id
)
ON
DELETE
CASCADE
,
PRIMARY
KEY
(
nodescontexts1
,
nodescontexts2
)
);
ALTER
TABLE
public
.
nodescontexts_nodescontexts
OWNER
TO
gargantua
;
CREATE
INDEX
ON
public
.
nodescontexts_nodescontexts
USING
btree
(
nodescontexts1
,
nodescontexts2
)
src/Gargantext/API/Client.hs
View file @
548c8d15
...
@@ -116,7 +116,7 @@ postNodeSearch :: Token -> NodeId -> SearchQuery -> Maybe Int -> Maybe Int -> Ma
...
@@ -116,7 +116,7 @@ postNodeSearch :: Token -> NodeId -> SearchQuery -> Maybe Int -> Maybe Int -> Ma
postNodeShare
::
Token
->
NodeId
->
ShareNodeParams
->
ClientM
Int
postNodeShare
::
Token
->
NodeId
->
ShareNodeParams
->
ClientM
Int
postNodePairCorpusAnnuaire
::
Token
->
NodeId
->
AnnuaireId
->
Maybe
ListId
->
ClientM
Int
postNodePairCorpusAnnuaire
::
Token
->
NodeId
->
AnnuaireId
->
Maybe
ListId
->
ClientM
[
Int
]
getNodePairs
::
Token
->
NodeId
->
ClientM
[
AnnuaireId
]
getNodePairs
::
Token
->
NodeId
->
ClientM
[
AnnuaireId
]
getNodePairings
::
Token
->
NodeId
->
Maybe
TabType
->
Maybe
Int
->
Maybe
Int
->
Maybe
Facet
.
OrderBy
->
ClientM
[
FacetDoc
]
getNodePairings
::
Token
->
NodeId
->
Maybe
TabType
->
Maybe
Int
->
Maybe
Int
->
Maybe
Facet
.
OrderBy
->
ClientM
[
FacetDoc
]
...
@@ -205,7 +205,7 @@ postCorpusSearch :: Token -> CorpusId -> SearchQuery -> Maybe Int -> Maybe Int -
...
@@ -205,7 +205,7 @@ postCorpusSearch :: Token -> CorpusId -> SearchQuery -> Maybe Int -> Maybe Int -
postCorpusShare
::
Token
->
CorpusId
->
ShareNodeParams
->
ClientM
Int
postCorpusShare
::
Token
->
CorpusId
->
ShareNodeParams
->
ClientM
Int
postCorpusPairCorpusAnnuaire
::
Token
->
CorpusId
->
AnnuaireId
->
Maybe
ListId
->
ClientM
Int
postCorpusPairCorpusAnnuaire
::
Token
->
CorpusId
->
AnnuaireId
->
Maybe
ListId
->
ClientM
[
Int
]
getCorpusPairs
::
Token
->
CorpusId
->
ClientM
[
AnnuaireId
]
getCorpusPairs
::
Token
->
CorpusId
->
ClientM
[
AnnuaireId
]
getCorpusPairings
::
Token
->
CorpusId
->
Maybe
TabType
->
Maybe
Int
->
Maybe
Int
->
Maybe
Facet
.
OrderBy
->
ClientM
[
FacetDoc
]
getCorpusPairings
::
Token
->
CorpusId
->
Maybe
TabType
->
Maybe
Int
->
Maybe
Int
->
Maybe
Facet
.
OrderBy
->
ClientM
[
FacetDoc
]
...
@@ -299,7 +299,7 @@ putAnnuaireScore :: Token -> AnnuaireId -> NodesToScore -> ClientM [Int]
...
@@ -299,7 +299,7 @@ putAnnuaireScore :: Token -> AnnuaireId -> NodesToScore -> ClientM [Int]
postAnnuaireSearch
::
Token
->
AnnuaireId
->
SearchQuery
->
Maybe
Int
->
Maybe
Int
->
Maybe
Facet
.
OrderBy
->
ClientM
SearchResult
postAnnuaireSearch
::
Token
->
AnnuaireId
->
SearchQuery
->
Maybe
Int
->
Maybe
Int
->
Maybe
Facet
.
OrderBy
->
ClientM
SearchResult
postAnnuaireShare
::
Token
->
AnnuaireId
->
ShareNodeParams
->
ClientM
Int
postAnnuaireShare
::
Token
->
AnnuaireId
->
ShareNodeParams
->
ClientM
Int
postAnnuairePairCorpusAnnuaire
::
Token
->
AnnuaireId
->
AnnuaireId
->
Maybe
ListId
->
ClientM
Int
postAnnuairePairCorpusAnnuaire
::
Token
->
AnnuaireId
->
AnnuaireId
->
Maybe
ListId
->
ClientM
[
Int
]
getAnnuairePairs
::
Token
->
AnnuaireId
->
ClientM
[
AnnuaireId
]
getAnnuairePairs
::
Token
->
AnnuaireId
->
ClientM
[
AnnuaireId
]
getAnnuairePairings
::
Token
->
AnnuaireId
->
Maybe
TabType
->
Maybe
Int
->
Maybe
Int
->
Maybe
Facet
.
OrderBy
->
ClientM
[
FacetDoc
]
getAnnuairePairings
::
Token
->
AnnuaireId
->
Maybe
TabType
->
Maybe
Int
->
Maybe
Int
->
Maybe
Facet
.
OrderBy
->
ClientM
[
FacetDoc
]
...
...
src/Gargantext/API/Ngrams/Tools.hs
View file @
548c8d15
...
@@ -135,16 +135,16 @@ filterListWithRootHashMap lt m = snd <$> HM.filter isMapTerm m
...
@@ -135,16 +135,16 @@ filterListWithRootHashMap lt m = snd <$> HM.filter isMapTerm m
Nothing
->
panic
$
"[Garg.API.Ngrams.Tools] filterWithRoot, unknown key: "
<>
unNgramsTerm
r
Nothing
->
panic
$
"[Garg.API.Ngrams.Tools] filterWithRoot, unknown key: "
<>
unNgramsTerm
r
Just
(
l'
,
_
)
->
l'
==
lt
Just
(
l'
,
_
)
->
l'
==
lt
filterListWithRoot
::
ListType
filterListWithRoot
::
[
ListType
]
->
HashMap
NgramsTerm
(
ListType
,
Maybe
NgramsTerm
)
->
HashMap
NgramsTerm
(
ListType
,
Maybe
NgramsTerm
)
->
HashMap
NgramsTerm
(
Maybe
RootTerm
)
->
HashMap
NgramsTerm
(
Maybe
RootTerm
)
filterListWithRoot
lt
m
=
snd
<$>
HM
.
filter
isMapTerm
m
filterListWithRoot
lt
m
=
snd
<$>
HM
.
filter
isMapTerm
m
where
where
isMapTerm
(
l
,
maybeRoot
)
=
case
maybeRoot
of
isMapTerm
(
l
,
maybeRoot
)
=
case
maybeRoot
of
Nothing
->
l
==
lt
Nothing
->
elem
l
lt
Just
r
->
case
HM
.
lookup
r
m
of
Just
r
->
case
HM
.
lookup
r
m
of
Nothing
->
panic
$
"[Garg.API.Ngrams.Tools] filterWithRoot, unknown key: "
<>
unNgramsTerm
r
Nothing
->
panic
$
"[Garg.API.Ngrams.Tools] filterWithRoot, unknown key: "
<>
unNgramsTerm
r
Just
(
l'
,
_
)
->
l'
==
lt
Just
(
l'
,
_
)
->
elem
l'
lt
groupNodesByNgrams
::
(
At
root_map
groupNodesByNgrams
::
(
At
root_map
,
Index
root_map
~
NgramsTerm
,
Index
root_map
~
NgramsTerm
...
...
src/Gargantext/API/Node.hs
View file @
548c8d15
...
@@ -312,7 +312,7 @@ pairs cId = do
...
@@ -312,7 +312,7 @@ pairs cId = do
type
PairWith
=
Summary
"Pair a Corpus with an Annuaire"
type
PairWith
=
Summary
"Pair a Corpus with an Annuaire"
:>
"annuaire"
:>
Capture
"annuaire_id"
AnnuaireId
:>
"annuaire"
:>
Capture
"annuaire_id"
AnnuaireId
:>
QueryParam
"list_id"
ListId
:>
QueryParam
"list_id"
ListId
:>
Post
'[
J
SON
]
Int
:>
Post
'[
J
SON
]
[
Int
]
pairWith
::
CorpusId
->
GargServer
PairWith
pairWith
::
CorpusId
->
GargServer
PairWith
pairWith
cId
aId
lId
=
do
pairWith
cId
aId
lId
=
do
...
...
src/Gargantext/API/Node/Corpus/Export.hs
View file @
548c8d15
...
@@ -95,7 +95,7 @@ getContextNgrams cId lId listType nt repo = do
...
@@ -95,7 +95,7 @@ getContextNgrams cId lId listType nt repo = do
-- Just l -> pure l
-- Just l -> pure l
lIds
<-
selectNodesWithUsername
NodeList
userMaster
lIds
<-
selectNodesWithUsername
NodeList
userMaster
let
ngs
=
filterListWithRoot
listType
$
mapTermListRoot
[
lId
]
nt
repo
let
ngs
=
filterListWithRoot
[
listType
]
$
mapTermListRoot
[
lId
]
nt
repo
-- TODO HashMap
-- TODO HashMap
r
<-
getNgramsByContextOnlyUser
cId
(
lIds
<>
[
lId
])
nt
(
HashMap
.
keys
ngs
)
r
<-
getNgramsByContextOnlyUser
cId
(
lIds
<>
[
lId
])
nt
(
HashMap
.
keys
ngs
)
pure
r
pure
r
...
...
src/Gargantext/Core/Viz/Chart.hs
View file @
548c8d15
...
@@ -61,7 +61,7 @@ chartData cId nt lt = do
...
@@ -61,7 +61,7 @@ chartData cId nt lt = do
ls
<-
map
(
_node_id
)
<$>
getListsWithParentId
cId
ls
<-
map
(
_node_id
)
<$>
getListsWithParentId
cId
ts
<-
mapTermListRoot
ls
nt
<$>
getRepo'
ls
ts
<-
mapTermListRoot
ls
nt
<$>
getRepo'
ls
let
let
dico
=
filterListWithRoot
lt
ts
dico
=
filterListWithRoot
[
lt
]
ts
terms
=
catMaybes
$
List
.
concat
$
map
(
\
(
a
,
b
)
->
[
Just
a
,
b
])
$
HashMap
.
toList
dico
terms
=
catMaybes
$
List
.
concat
$
map
(
\
(
a
,
b
)
->
[
Just
a
,
b
])
$
HashMap
.
toList
dico
group
dico'
x
=
case
HashMap
.
lookup
x
dico'
of
group
dico'
x
=
case
HashMap
.
lookup
x
dico'
of
Nothing
->
x
Nothing
->
x
...
@@ -86,7 +86,7 @@ treeData cId nt lt = do
...
@@ -86,7 +86,7 @@ treeData cId nt lt = do
ts
<-
mapTermListRoot
ls
nt
<$>
getRepo'
ls
ts
<-
mapTermListRoot
ls
nt
<$>
getRepo'
ls
let
let
dico
=
filterListWithRoot
lt
ts
dico
=
filterListWithRoot
[
lt
]
ts
terms
=
catMaybes
$
List
.
concat
$
map
(
\
(
a
,
b
)
->
[
Just
a
,
b
])
$
HashMap
.
toList
dico
terms
=
catMaybes
$
List
.
concat
$
map
(
\
(
a
,
b
)
->
[
Just
a
,
b
])
$
HashMap
.
toList
dico
cs'
<-
getContextsByNgramsOnlyUser
cId
(
ls'
<>
ls
)
nt
terms
cs'
<-
getContextsByNgramsOnlyUser
cId
(
ls'
<>
ls
)
nt
terms
...
...
src/Gargantext/Core/Viz/Graph/API.hs
View file @
548c8d15
...
@@ -174,7 +174,7 @@ computeGraph cId method d nt repo = do
...
@@ -174,7 +174,7 @@ computeGraph cId method d nt repo = do
lId
<-
defaultList
cId
lId
<-
defaultList
cId
lIds
<-
selectNodesWithUsername
NodeList
userMaster
lIds
<-
selectNodesWithUsername
NodeList
userMaster
let
ngs
=
filterListWithRoot
MapTerm
let
ngs
=
filterListWithRoot
[
MapTerm
]
$
mapTermListRoot
[
lId
]
nt
repo
$
mapTermListRoot
[
lId
]
nt
repo
myCooc
<-
HashMap
.
filter
(
>
1
)
-- Removing the hapax (ngrams with 1 cooc)
myCooc
<-
HashMap
.
filter
(
>
1
)
-- Removing the hapax (ngrams with 1 cooc)
...
...
src/Gargantext/Database/Action/Flow/Pairing.hs
View file @
548c8d15
...
@@ -16,15 +16,18 @@ module Gargantext.Database.Action.Flow.Pairing
...
@@ -16,15 +16,18 @@ module Gargantext.Database.Action.Flow.Pairing
-- (pairing)
-- (pairing)
where
where
import
Debug.Trace
(
trace
)
import
Control.Lens
(
_Just
,
(
^.
))
import
Control.Lens
(
_Just
,
(
^.
))
import
Data.Hashable
(
Hashable
)
import
Data.HashMap.Strict
(
HashMap
)
import
Data.HashMap.Strict
(
HashMap
)
import
qualified
Data.HashMap.Strict
as
HM
import
Data.Maybe
(
fromMaybe
,
catMaybes
)
import
Data.Maybe
(
catMaybes
,
fromMaybe
)
import
Data.Set
(
Set
)
import
Data.Set
(
Set
)
import
Data.Text
(
Text
)
import
Gargantext.API.Ngrams.Tools
import
Gargantext.API.Ngrams.Tools
import
Gargantext.API.Ngrams.Types
(
NgramsTerm
(
..
))
import
Gargantext.API.Ngrams.Types
(
NgramsTerm
(
..
))
import
Gargantext.API.Prelude
(
GargNoServer
)
import
Gargantext.API.Prelude
(
GargNoServer
)
import
Gargantext.Core
import
Gargantext.Core
import
Gargantext.Core.Text.Metrics.CharByChar
(
levenshtein
)
import
Gargantext.Core.Types
(
TableResult
(
..
))
import
Gargantext.Core.Types
(
TableResult
(
..
))
import
Gargantext.Core.Types.Main
import
Gargantext.Core.Types.Main
import
Gargantext.Database
import
Gargantext.Database
...
@@ -33,18 +36,21 @@ import Gargantext.Database.Admin.Config
...
@@ -33,18 +36,21 @@ import Gargantext.Database.Admin.Config
import
Gargantext.Database.Admin.Types.Hyperdata
-- (HyperdataContact(..))
import
Gargantext.Database.Admin.Types.Hyperdata
-- (HyperdataContact(..))
import
Gargantext.Database.Admin.Types.Node
-- (AnnuaireId, CorpusId, ListId, DocId, ContactId, NodeId)
import
Gargantext.Database.Admin.Types.Node
-- (AnnuaireId, CorpusId, ListId, DocId, ContactId, NodeId)
import
Gargantext.Database.Query.Prelude
(
leftJoin2
,
returnA
,
queryNodeNodeTable
)
import
Gargantext.Database.Query.Prelude
(
leftJoin2
,
returnA
,
queryNodeNodeTable
)
import
Gargantext.Database.Query.Table.Node
(
defaultList
)
import
Gargantext.Database.Query.Table.Node.Children
(
getAllContacts
)
import
Gargantext.Database.Query.Table.Node.Children
(
getAllContacts
)
import
Gargantext.Database.Query.Table.Node.Select
(
selectNodesWithUsername
)
import
Gargantext.Database.Query.Table.Node.Select
(
selectNodesWithUsername
)
import
Gargantext.Database.Query.Table.Node
(
defaultLis
t
)
import
Gargantext.Database.Query.Table.Node
Context_NodeContext
(
insertNodeContext_NodeContex
t
)
import
Gargantext.Database.Query.Table.NodeNode
(
insertNodeNode
)
import
Gargantext.Database.Query.Table.NodeNode
(
insertNodeNode
)
import
Gargantext.Database.Schema.Ngrams
-- (NgramsType(..))
import
Gargantext.Database.Schema.Ngrams
-- (NgramsType(..))
import
Gargantext.Database.Schema.Node
import
Gargantext.Database.Schema.Node
-- import Gargantext.Database.Schema.Context
import
qualified
Data.HashMap.Strict
as
HM
import
Gargantext.Prelude
hiding
(
sum
)
import
Gargantext.Prelude
hiding
(
sum
)
import
Opaleye
import
Opaleye
import
qualified
Data.HashMap.Strict
as
HashMap
import
qualified
Data.HashMap.Strict
as
HashMap
import
qualified
Data.List
as
List
import
qualified
Data.List
as
List
import
qualified
Data.Set
as
Set
import
qualified
Data.Set
as
Set
import
qualified
Data.Text
as
DT
import
qualified
Data.Text
as
Text
-- | isPairedWith
-- | isPairedWith
-- All NodeAnnuaire paired with a Corpus of NodeId nId:
-- All NodeAnnuaire paired with a Corpus of NodeId nId:
...
@@ -65,120 +71,117 @@ isPairedWith nId nt = runOpaQuery (selectQuery nt nId)
...
@@ -65,120 +71,117 @@ isPairedWith nId nt = runOpaQuery (selectQuery nt nId)
cond
(
node
,
node_node
)
=
node
^.
node_id
.==
node_node
^.
nn_node2_id
cond
(
node
,
node_node
)
=
node
^.
node_id
.==
node_node
^.
nn_node2_id
-----------------------------------------------------------------------
-----------------------------------------------------------------------
pairing
::
AnnuaireId
->
CorpusId
->
Maybe
ListId
->
GargNoServer
Int
pairing
::
AnnuaireId
->
CorpusId
->
Maybe
ListId
->
GargNoServer
[
Int
]
pairing
a
c
l'
=
do
pairing
a
c
l'
=
do
l
<-
case
l'
of
l
<-
case
l'
of
Nothing
->
defaultList
c
Nothing
->
defaultList
c
Just
l''
->
pure
l''
Just
l''
->
pure
l''
dataPaired
<-
dataPairing
a
(
c
,
l
,
Authors
)
takeName
takeName
dataPaired
<-
dataPairing
a
(
c
,
l
,
Authors
)
r
<-
insertDB
$
prepareInsert
dataPaired
_
<-
insertNodeNode
[
NodeNode
c
a
Nothing
Nothing
]
_
<-
insertNodeNode
[
NodeNode
{
_nn_node1_id
=
c
insertNodeContext_NodeContext
$
prepareInsert
c
a
dataPaired
,
_nn_node2_id
=
a
,
_nn_score
=
Nothing
,
_nn_category
=
Nothing
}]
pure
r
dataPairing
::
AnnuaireId
dataPairing
::
AnnuaireId
->
(
CorpusId
,
ListId
,
NgramsType
)
->
(
CorpusId
,
ListId
,
NgramsType
)
->
(
ContactName
->
Projected
)
->
(
DocAuthor
->
Projected
)
->
GargNoServer
(
HashMap
ContactId
(
Set
DocId
))
->
GargNoServer
(
HashMap
ContactId
(
Set
DocId
))
dataPairing
aId
(
cId
,
lId
,
ngt
)
fc
fa
=
do
dataPairing
aId
(
cId
,
lId
,
ngt
)
=
do
-- mc :: HM.HashMap ContactName (Set ContactId)
mc
<-
getNgramsContactId
aId
mc
<-
getNgramsContactId
aId
md
<-
getNgramsDocId
cId
lId
ngt
-- md :: HM.HashMap DocAuthor (Set DocId)
md
<-
getNgramsDocId
cId
lId
ngt
printDebug
"ngramsContactId"
mc
-- printDebug "dataPairing authors" (HM.keys md)
printDebug
"ngramsDocId"
md
let
result
=
fusion
mc
md
let
-- printDebug "dataPairing" (length $ HM.keys result)
from
=
projectionFrom
(
Set
.
fromList
$
HM
.
keys
mc
)
fc
pure
result
to
=
projectionTo
(
Set
.
fromList
$
HM
.
keys
md
)
fa
pure
$
fusion
mc
$
align
from
to
md
prepareInsert
::
CorpusId
->
AnnuaireId
->
HashMap
ContactId
(
Set
DocId
)
->
[(
CorpusId
,
AnnuaireId
,
DocId
,
ContactId
)]
prepareInsert
corpusId
annuaireId
mapContactDocs
=
map
(
\
(
contactId
,
docId
)
->
(
corpusId
,
docId
,
annuaireId
,
contactId
))
prepareInsert
::
HashMap
ContactId
(
Set
DocId
)
->
[
NodeNode
]
$
List
.
concat
prepareInsert
m
=
map
(
\
(
n1
,
n2
)
->
NodeNode
{
_nn_node1_id
=
n1
$
map
(
\
(
contactId
,
setDocIds
)
,
_nn_node2_id
=
n2
->
map
(
\
setDocId
,
_nn_score
=
Nothing
->
(
contactId
,
setDocId
)
,
_nn_category
=
Nothing
})
)
$
Set
.
toList
setDocIds
$
List
.
concat
)
$
map
(
\
(
contactId
,
setDocIds
)
$
HM
.
toList
mapContactDocs
->
map
(
\
setDocId
->
(
contactId
,
setDocId
)
)
$
Set
.
toList
setDocIds
)
$
HM
.
toList
m
------------------------------------------------------------------------
------------------------------------------------------------------------
type
ContactName
=
NgramsTerm
type
ContactName
=
NgramsTerm
type
DocAuthor
=
NgramsTerm
type
DocAuthor
=
NgramsTerm
type
Projected
=
NgramsTerm
type
Projected
=
NgramsTerm
projectionFrom
::
Set
ContactName
->
(
ContactName
->
Projected
)
->
HashMap
ContactName
Projected
fusion
::
HashMap
ContactName
(
Set
ContactId
)
projectionFrom
ss
f
=
HM
.
fromList
$
map
(
\
s
->
(
s
,
f
s
))
(
Set
.
toList
ss
)
-- use HS.toMap
->
HashMap
DocAuthor
(
Set
DocId
)
->
HashMap
ContactId
(
Set
DocId
)
fusion
mc
md
=
HM
.
fromListWith
(
<>
)
$
List
.
concat
$
map
(
\
(
docAuthor
,
docs
)
->
case
(
getClosest
Text
.
toLower
docAuthor
(
HM
.
keys
mc
))
of
Nothing
->
[]
Just
author
->
case
HM
.
lookup
author
mc
of
Nothing
->
[]
Just
contactIds
->
map
(
\
contactId
->
(
contactId
,
docs
))
$
Set
.
toList
contactIds
)
$
HM
.
toList
md
fusion''
::
HashMap
ContactName
(
Set
ContactId
)
->
HashMap
DocAuthor
(
Set
DocId
)
->
HashMap
ContactId
(
Set
DocId
)
fusion''
mc
md
=
hashmapReverse
$
fusion'
mc
(
hashmapReverse
md
)
projectionTo
::
Set
DocAuthor
->
(
DocAuthor
->
Projected
)
->
HashMap
Projected
(
Set
DocAuthor
)
fusion'
::
HashMap
ContactName
(
Set
ContactId
)
projectionTo
ss
f
=
HM
.
fromListWith
(
<>
)
$
map
(
\
s
->
(
f
s
,
Set
.
singleton
s
))
(
Set
.
toList
ss
)
-- use HS.toMap
->
HashMap
DocId
(
Set
DocAuthor
)
------------------------------------------------------------------------
->
HashMap
DocId
(
Set
ContactId
)
takeName
::
NgramsTerm
->
NgramsTerm
fusion'
mc
md
=
HM
.
fromListWith
(
<>
)
takeName
(
NgramsTerm
texte
)
=
NgramsTerm
$
DT
.
toLower
texte'
$
map
(
\
(
docId
,
setAuthors
)
->
(
docId
,
getContactIds
mc
$
getClosest'
setAuthors
(
HM
.
keys
mc
)))
$
HM
.
toList
md
getContactIds
::
HashMap
ContactName
(
Set
ContactId
)
->
Set
ContactName
->
Set
ContactId
getContactIds
mapContactNames
contactNames
=
if
Set
.
null
contactNames
then
Set
.
empty
else
Set
.
unions
$
catMaybes
$
map
(
\
contactName
->
HM
.
lookup
contactName
mapContactNames
)
$
Set
.
toList
contactNames
getClosest'
::
Set
DocAuthor
->
[
ContactName
]
->
Set
ContactName
getClosest'
setAuthors
contactNames
=
trace
(
show
(
setAuthors
,
setContactNames
))
$
setContactNames
where
where
texte'
=
maybe
texte
(
\
x
->
if
DT
.
length
x
>
3
then
x
else
texte
)
setContactNames
=
if
Set
.
null
xs
then
ys
else
xs
(
lastName'
texte
)
xs
=
Set
.
fromList
$
catMaybes
$
map
(
\
author
->
getClosest
Text
.
toLower
author
contactNames
)
$
Set
.
toList
setAuthors
lastName'
=
lastMay
.
DT
.
splitOn
" "
ys
=
Set
.
fromList
$
catMaybes
$
map
(
\
(
NgramsTerm
author
)
->
case
((
lastMay
.
(
Text
.
splitOn
" "
))
author
)
of
Nothing
->
Nothing
Just
authorReduced
->
getClosest
Text
.
toLower
(
NgramsTerm
authorReduced
)
contactNames
)
$
Set
.
toList
setAuthors
------------------------------------------------------------------------
getClosest
::
(
Text
->
Text
)
->
NgramsTerm
->
[
NgramsTerm
]
->
Maybe
NgramsTerm
align
::
HashMap
ContactName
Projected
getClosest
f
(
NgramsTerm
from
)
candidates
=
fst
<$>
head
scored
->
HashMap
Projected
(
Set
DocAuthor
)
->
HashMap
DocAuthor
(
Set
DocId
)
->
HashMap
ContactName
(
Set
DocId
)
align
mc
ma
md
=
HM
.
fromListWith
(
<>
)
$
map
(
\
c
->
(
c
,
getProjection
md
$
testProjection
c
mc
ma
))
$
HM
.
keys
mc
where
where
getProjection
::
HashMap
DocAuthor
(
Set
DocId
)
->
Set
DocAuthor
->
Set
DocId
scored
=
List
.
sortOn
snd
getProjection
ma'
sa'
=
$
List
.
filter
(
\
(
_
,
score
)
->
score
<=
2
)
if
Set
.
null
sa'
$
map
(
\
cand
@
(
NgramsTerm
candidate
)
->
(
cand
,
levenshtein
(
f
from
)
(
f
candidate
)))
candidates
then
Set
.
empty
else
Set
.
unions
$
sets
ma'
sa'
where
sets
ma''
sa''
=
Set
.
map
(
\
s
->
lookup
s
ma''
)
sa''
lookup
s'
ma''
=
fromMaybe
Set
.
empty
(
HM
.
lookup
s'
ma''
)
testProjection
::
ContactName
->
HashMap
ContactName
Projected
->
HashMap
Projected
(
Set
DocAuthor
)
->
Set
DocAuthor
testProjection
cn'
mc'
ma'
=
case
HM
.
lookup
cn'
mc'
of
Nothing
->
Set
.
empty
Just
c
->
case
HM
.
lookup
c
ma'
of
Nothing
->
Set
.
empty
Just
a
->
a
fusion
::
HashMap
ContactName
(
Set
ContactId
)
->
HashMap
ContactName
(
Set
DocId
)
->
HashMap
ContactId
(
Set
DocId
)
fusion
mc
md
=
HM
.
fromListWith
(
<>
)
$
catMaybes
$
[
(,)
<$>
Just
cId
<*>
HM
.
lookup
cn
md
|
(
cn
,
setContactId
)
<-
HM
.
toList
mc
,
cId
<-
Set
.
toList
setContactId
]
------------------------------------------------------------------------
------------------------------------------------------------------------
getNgramsContactId
::
AnnuaireId
getNgramsContactId
::
AnnuaireId
->
Cmd
err
(
HashMap
ContactName
(
Set
NodeId
))
->
Cmd
err
(
HashMap
ContactName
(
Set
NodeId
))
getNgramsContactId
aId
=
do
getNgramsContactId
aId
=
do
contacts
<-
getAllContacts
aId
contacts
<-
getAllContacts
aId
pure
$
HM
.
fromListWith
(
<>
)
-- printDebug "getAllContexts" (tr_count contacts)
$
catMaybes
let
paired
=
HM
.
fromListWith
(
<>
)
$
map
(
\
contact
->
(,)
<$>
(
NgramsTerm
<$>
contact
^.
(
node_hyperdata
.
hc_who
.
_Just
.
cw_lastName
))
$
map
(
\
contact
->
(
toName
contact
,
Set
.
singleton
(
contact
^.
node_id
))
<*>
Just
(
Set
.
singleton
(
contact
^.
node_id
))
)
(
tr_docs
contacts
)
)
(
tr_docs
contacts
)
-- printDebug "paired" (HM.keys paired)
pure
paired
-- POC here, should be a probabilistic function (see the one used to find lang)
toName
::
Node
HyperdataContact
->
NgramsTerm
toName
contact
=
NgramsTerm
$
(
Text
.
toTitle
$
Text
.
take
1
firstName
)
<>
". "
<>
(
Text
.
toTitle
lastName
)
where
firstName
=
fromMaybe
""
$
contact
^.
(
node_hyperdata
.
hc_who
.
_Just
.
cw_firstName
)
lastName
=
fromMaybe
""
$
contact
^.
(
node_hyperdata
.
hc_who
.
_Just
.
cw_lastName
)
getNgramsDocId
::
CorpusId
getNgramsDocId
::
CorpusId
->
ListId
->
ListId
...
@@ -186,8 +189,15 @@ getNgramsDocId :: CorpusId
...
@@ -186,8 +189,15 @@ getNgramsDocId :: CorpusId
->
GargNoServer
(
HashMap
DocAuthor
(
Set
NodeId
))
->
GargNoServer
(
HashMap
DocAuthor
(
Set
NodeId
))
getNgramsDocId
cId
lId
nt
=
do
getNgramsDocId
cId
lId
nt
=
do
lIds
<-
selectNodesWithUsername
NodeList
userMaster
lIds
<-
selectNodesWithUsername
NodeList
userMaster
repo
<-
getRepo'
lIds
repo
<-
getRepo'
(
lId
:
lIds
)
let
ngs
=
filterListWithRoot
MapTerm
$
mapTermListRoot
[
lId
]
nt
repo
let
ngs
=
filterListWithRoot
[
MapTerm
,
CandidateTerm
]
$
mapTermListRoot
(
lId
:
lIds
)
nt
repo
-- printDebug "getNgramsDocId" ngs
groupNodesByNgrams
ngs
<$>
getContextsByNgramsOnlyUser
cId
(
lIds
<>
[
lId
])
nt
(
HashMap
.
keys
ngs
)
groupNodesByNgrams
ngs
<$>
getContextsByNgramsOnlyUser
cId
(
lIds
<>
[
lId
])
nt
(
HashMap
.
keys
ngs
)
hashmapReverse
::
(
Ord
a
,
Eq
b
,
Hashable
b
)
=>
HashMap
a
(
Set
b
)
->
HashMap
b
(
Set
a
)
hashmapReverse
m
=
HM
.
fromListWith
(
<>
)
$
List
.
concat
$
map
(
\
(
k
,
vs
)
->
[
(
v
,
Set
.
singleton
k
)
|
v
<-
Set
.
toList
vs
])
$
HM
.
toList
m
src/Gargantext/Database/Action/Metrics.hs
View file @
548c8d15
...
@@ -234,8 +234,9 @@ getNgrams :: (HasMail env, HasNodeStory env err m)
...
@@ -234,8 +234,9 @@ getNgrams :: (HasMail env, HasNodeStory env err m)
getNgrams
lId
tabType
=
do
getNgrams
lId
tabType
=
do
lists
<-
mapTermListRoot
[
lId
]
(
ngramsTypeFromTabType
tabType
)
<$>
getRepo'
[
lId
]
lists
<-
mapTermListRoot
[
lId
]
(
ngramsTypeFromTabType
tabType
)
<$>
getRepo'
[
lId
]
-- TODO filterListWithRoot [MapTerm, StopTerm, CandidateTerm] lists
let
maybeSyn
=
HM
.
unions
$
map
(
\
t
->
filterListWithRoot
t
lists
)
let
maybeSyn
=
HM
.
unions
$
map
(
\
t
->
filterListWithRoot
t
lists
)
[
MapTerm
,
StopTerm
,
CandidateTerm
]
[
[
MapTerm
],
[
StopTerm
],
[
CandidateTerm
]
]
pure
(
lists
,
maybeSyn
)
pure
(
lists
,
maybeSyn
)
-- Some useful Tools
-- Some useful Tools
...
...
src/Gargantext/Database/Action/Metrics/NgramsByContext.hs
View file @
548c8d15
...
@@ -172,7 +172,7 @@ selectNgramsOccurrencesOnlyByContextUser_withSample cId int nt tms =
...
@@ -172,7 +172,7 @@ selectNgramsOccurrencesOnlyByContextUser_withSample cId int nt tms =
queryNgramsOccurrencesOnlyByContextUser_withSample
::
DPS
.
Query
queryNgramsOccurrencesOnlyByContextUser_withSample
::
DPS
.
Query
queryNgramsOccurrencesOnlyByContextUser_withSample
=
[
sql
|
queryNgramsOccurrencesOnlyByContextUser_withSample
=
[
sql
|
WITH nodes_sample AS (SELECT id FROM contexts n TABLESAMPLE SYSTEM_ROWS (?)
WITH nodes_sample AS (SELECT
n.
id FROM contexts n TABLESAMPLE SYSTEM_ROWS (?)
JOIN nodes_contexts nn ON n.id = nn.context_id
JOIN nodes_contexts nn ON n.id = nn.context_id
WHERE n.typename = ?
WHERE n.typename = ?
AND nn.node_id = ?),
AND nn.node_id = ?),
...
...
src/Gargantext/Database/Action/Search.hs
View file @
548c8d15
...
@@ -26,8 +26,8 @@ import Gargantext.Database.Query.Filter
...
@@ -26,8 +26,8 @@ import Gargantext.Database.Query.Filter
import
Gargantext.Database.Query.Join
(
leftJoin5
)
import
Gargantext.Database.Query.Join
(
leftJoin5
)
import
Gargantext.Database.Query.Table.Node
import
Gargantext.Database.Query.Table.Node
import
Gargantext.Database.Query.Table.Context
import
Gargantext.Database.Query.Table.Context
import
Gargantext.Database.Query.Table.NodeNode
import
Gargantext.Database.Query.Table.NodeContext
import
Gargantext.Database.Query.Table.NodeContext
import
Gargantext.Database.Query.Table.NodeContext_NodeContext
import
Gargantext.Database.Schema.Node
import
Gargantext.Database.Schema.Node
import
Gargantext.Database.Schema.Context
import
Gargantext.Database.Schema.Context
import
Gargantext.Prelude
import
Gargantext.Prelude
...
@@ -41,11 +41,11 @@ searchDocInDatabase :: HasDBid NodeType
...
@@ -41,11 +41,11 @@ searchDocInDatabase :: HasDBid NodeType
=>
ParentId
=>
ParentId
->
Text
->
Text
->
Cmd
err
[(
NodeId
,
HyperdataDocument
)]
->
Cmd
err
[(
NodeId
,
HyperdataDocument
)]
searchDocInDatabase
_p
t
=
runOpaQuery
(
queryDocInDatabase
t
)
searchDocInDatabase
p
t
=
runOpaQuery
(
queryDocInDatabase
p
t
)
where
where
-- | Global search query where ParentId is Master Node Corpus Id
-- | Global search query where ParentId is Master Node Corpus Id
queryDocInDatabase
::
Text
->
O
.
Select
(
Column
SqlInt4
,
Column
SqlJsonb
)
queryDocInDatabase
::
ParentId
->
Text
->
O
.
Select
(
Column
SqlInt4
,
Column
SqlJsonb
)
queryDocInDatabase
q
=
proc
()
->
do
queryDocInDatabase
_p
q
=
proc
()
->
do
row
<-
queryNodeSearchTable
-<
()
row
<-
queryNodeSearchTable
-<
()
restrict
-<
(
_ns_search
row
)
@@
(
sqlTSQuery
(
unpack
q
))
restrict
-<
(
_ns_search
row
)
@@
(
sqlTSQuery
(
unpack
q
))
restrict
-<
(
_ns_typename
row
)
.==
(
sqlInt4
$
toDBid
NodeDocument
)
restrict
-<
(
_ns_typename
row
)
.==
(
sqlInt4
$
toDBid
NodeDocument
)
...
@@ -118,11 +118,22 @@ searchInCorpusWithContacts
...
@@ -118,11 +118,22 @@ searchInCorpusWithContacts
searchInCorpusWithContacts
cId
aId
q
o
l
_order
=
searchInCorpusWithContacts
cId
aId
q
o
l
_order
=
runOpaQuery
$
limit'
l
runOpaQuery
$
limit'
l
$
offset'
o
$
offset'
o
$
orderBy
(
desc
_fp_score
)
$
orderBy
(
desc
_fp_score
)
$
selectGroup
cId
aId
$
selectGroup
cId
aId
$
intercalate
" | "
$
intercalate
" | "
$
map
stemIt
q
$
map
stemIt
q
selectGroup
::
HasDBid
NodeType
=>
CorpusId
->
AnnuaireId
->
Text
->
Select
FacetPairedReadNull
selectGroup
cId
aId
q
=
proc
()
->
do
(
a
,
b
,
c
,
d
)
<-
aggregate
(
p4
(
groupBy
,
groupBy
,
groupBy
,
O
.
sum
))
(
selectContactViaDoc
cId
aId
q
)
-<
()
returnA
-<
FacetPaired
a
b
c
d
selectContactViaDoc
selectContactViaDoc
::
HasDBid
NodeType
::
HasDBid
NodeType
=>
CorpusId
=>
CorpusId
...
@@ -134,81 +145,68 @@ selectContactViaDoc
...
@@ -134,81 +145,68 @@ selectContactViaDoc
,
Column
(
Nullable
SqlJsonb
)
,
Column
(
Nullable
SqlJsonb
)
,
Column
(
Nullable
SqlInt4
)
,
Column
(
Nullable
SqlInt4
)
)
)
selectContactViaDoc
cId
aId
q
=
proc
()
->
do
selectContactViaDoc
cId
aId
q
uery
=
proc
()
->
do
(
doc
,
(
corpus
_doc
,
(
_contact_doc
,
(
annuaire_contact
,
contact
))))
<-
queryContactViaDoc
-<
()
(
doc
,
(
corpus
,
(
_nodeContext_nodeContext
,
(
annuaire
,
contact
))))
<-
queryContactViaDoc
-<
()
restrict
-<
(
doc
^.
ns_search
)
@@
(
sqlTSQuery
$
unpack
q
)
restrict
-<
(
doc
^.
cs_search
)
@@
(
sqlTSQuery
$
unpack
query
)
restrict
-<
(
doc
^.
ns_typename
)
.==
(
sqlInt4
$
toDBid
NodeDocument
)
restrict
-<
(
doc
^.
cs_typename
)
.==
(
sqlInt4
$
toDBid
NodeDocument
)
restrict
-<
(
corpus
_doc
^.
nn_node1_id
)
.==
(
toNullable
$
pgNodeId
cId
)
restrict
-<
(
corpus
^.
nc_node_id
)
.==
(
toNullable
$
pgNodeId
cId
)
restrict
-<
(
annuaire
_contact
^.
nn_node1_id
)
.==
(
toNullable
$
pgNodeId
aId
)
restrict
-<
(
annuaire
^.
nc_node_id
)
.==
(
toNullable
$
pgNodeId
aId
)
restrict
-<
(
contact
^.
node_typename
)
.==
(
toNullable
$
sqlInt4
$
toDBid
NodeContact
)
restrict
-<
(
contact
^.
context_typename
)
.==
(
toNullable
$
sqlInt4
$
toDBid
NodeContact
)
returnA
-<
(
contact
^.
node
_id
returnA
-<
(
contact
^.
context
_id
,
contact
^.
node
_date
,
contact
^.
context
_date
,
contact
^.
node
_hyperdata
,
contact
^.
context
_hyperdata
,
toNullable
$
sqlInt4
1
,
toNullable
$
sqlInt4
1
)
)
selectGroup
::
HasDBid
NodeType
queryContactViaDoc
::
O
.
Select
(
ContextSearchRead
=>
NodeId
,
(
NodeContextReadNull
->
NodeId
,
(
NodeContext_NodeContextReadNull
->
Text
,
(
NodeContextReadNull
->
Select
FacetPairedReadNull
,
ContextReadNull
selectGroup
cId
aId
q
=
proc
()
->
do
(
a
,
b
,
c
,
d
)
<-
aggregate
(
p4
(
groupBy
,
groupBy
,
groupBy
,
O
.
sum
))
(
selectContactViaDoc
cId
aId
q
)
-<
()
returnA
-<
FacetPaired
a
b
c
d
queryContactViaDoc
::
O
.
Select
(
NodeSearchRead
,
(
NodeNodeReadNull
,
(
NodeNodeReadNull
,
(
NodeNodeReadNull
,
NodeReadNull
)
)
)
)
)
)
)
)
queryContactViaDoc
=
queryContactViaDoc
=
leftJoin5
leftJoin5
query
Node
Table
query
Context
Table
queryNode
Node
Table
queryNode
Context
Table
queryNode
Node
Table
queryNode
Context_NodeContext
Table
queryNode
Node
Table
queryNode
Context
Table
query
Node
SearchTable
query
Context
SearchTable
cond12
cond12
cond23
cond23
cond34
cond34
cond45
cond45
where
where
cond12
::
(
Node
NodeRead
,
Node
Read
)
->
Column
SqlBool
cond12
::
(
Node
ContextRead
,
Context
Read
)
->
Column
SqlBool
cond12
(
annuaire
_contact
,
contact
)
=
contact
^.
node_id
.==
annuaire_contact
^.
nn_node2
_id
cond12
(
annuaire
,
contact
)
=
contact
^.
context_id
.==
annuaire
^.
nc_context
_id
cond23
::
(
Node
Node
Read
cond23
::
(
Node
Context_NodeContext
Read
,
(
Node
Node
Read
,
(
Node
Context
Read
,
Node
ReadNull
,
Context
ReadNull
)
)
)
->
Column
SqlBool
)
->
Column
SqlBool
cond23
(
contact_doc
,
(
annuaire_contact
,
_
))
=
contact_doc
^.
nn_node1_id
.==
annuaire_contact
^.
nn_node2
_id
cond23
(
nodeContext_nodeContext
,
(
annuaire
,
_
))
=
nodeContext_nodeContext
^.
ncnc_nodecontext2
.==
annuaire
^.
nc
_id
cond34
::
(
Node
Node
Read
cond34
::
(
Node
Context
Read
,
(
Node
Node
Read
,
(
Node
Context_NodeContext
Read
,
(
Node
Node
ReadNull
,
(
Node
Context
ReadNull
,
Node
ReadNull
,
Context
ReadNull
)
)
)
)
)
->
Column
SqlBool
)
->
Column
SqlBool
cond34
(
corpus
_doc
,
(
contact_doc
,
(
_
,
_
)))
=
corpus_doc
^.
nn_node2_id
.==
contact_doc
^.
nn_node2
_id
cond34
(
corpus
,
(
nodeContext_nodeContext
,
(
_
,
_
)))
=
nodeContext_nodeContext
^.
ncnc_nodecontext1
.==
corpus
^.
nc
_id
cond45
::
(
Node
SearchRead
cond45
::
(
Context
SearchRead
,
(
Node
Node
Read
,
(
Node
Context
Read
,
(
Node
Node
ReadNull
,
(
Node
Context_NodeContext
ReadNull
,
(
Node
Node
ReadNull
,
(
Node
Context
ReadNull
,
Node
ReadNull
,
Context
ReadNull
)
)
)
)
)
)
)
->
Column
SqlBool
)
->
Column
SqlBool
cond45
(
doc
,
(
corpus
_doc
,
(
_
,(
_
,
_
))))
=
doc
^.
ns_id
.==
corpus_doc
^.
nn_node2
_id
cond45
(
doc
,
(
corpus
,
(
_
,(
_
,
_
))))
=
doc
^.
cs_id
.==
corpus
^.
nc_context
_id
------------------------------------------------------------------------
src/Gargantext/Database/Admin/Types/Node.hs
View file @
548c8d15
...
@@ -187,13 +187,13 @@ instance (Arbitrary hyperdata
...
@@ -187,13 +187,13 @@ instance (Arbitrary hyperdata
)
where
)
where
--arbitrary = Node 1 1 (Just 1) 1 "name" (jour 2018 01 01) (arbitrary) (Just "")
--arbitrary = Node 1 1 (Just 1) 1 "name" (jour 2018 01 01) (arbitrary) (Just "")
arbitrary
=
ContextSearch
<$>
arbitrary
arbitrary
=
ContextSearch
<$>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
<*>
arbitrary
...
@@ -212,10 +212,13 @@ pgContextId = pgNodeId
...
@@ -212,10 +212,13 @@ pgContextId = pgNodeId
newtype
NodeId
=
NodeId
Int
newtype
NodeId
=
NodeId
Int
deriving
(
Read
,
Generic
,
Num
,
Eq
,
Ord
,
Enum
,
ToJSONKey
,
FromJSONKey
,
ToJSON
,
FromJSON
,
Hashable
,
Csv
.
ToField
)
deriving
(
Read
,
Generic
,
Num
,
Eq
,
Ord
,
Enum
,
ToJSONKey
,
FromJSONKey
,
ToJSON
,
FromJSON
,
Hashable
,
Csv
.
ToField
)
-- TODO make another type
-- TODO make another type?
type
ContextId
=
NodeId
type
ContextId
=
NodeId
newtype
NodeContextId
=
NodeContextId
Int
deriving
(
Read
,
Generic
,
Num
,
Eq
,
Ord
,
Enum
,
ToJSONKey
,
FromJSONKey
,
ToJSON
,
FromJSON
,
Hashable
,
Csv
.
ToField
)
instance
GQLType
NodeId
instance
GQLType
NodeId
instance
Show
NodeId
where
instance
Show
NodeId
where
show
(
NodeId
n
)
=
"nodeId-"
<>
show
n
show
(
NodeId
n
)
=
"nodeId-"
<>
show
n
...
...
src/Gargantext/Database/Query/Table/Context.hs
View file @
548c8d15
{-|
{-|
import Gargantext.Database.Prelude (Cmd, runPGSQuery)
Module : Gargantext.Database.Query.Table.Node
Module : Gargantext.Database.Query.Table.Node
Description : Main Tools of Node to the database
Description : Main Tools of Node to the database
Copyright : (c) CNRS, 2017-Present
Copyright : (c) CNRS, 2017-Present
...
@@ -9,7 +8,6 @@ Stability : experimental
...
@@ -9,7 +8,6 @@ Stability : experimental
Portability : POSIX
Portability : POSIX
-}
-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE Arrows #-}
...
@@ -31,8 +29,8 @@ import Gargantext.Database.Query.Filter (limit', offset')
...
@@ -31,8 +29,8 @@ import Gargantext.Database.Query.Filter (limit', offset')
import
Gargantext.Database.Query.Table.Node.Error
import
Gargantext.Database.Query.Table.Node.Error
import
Gargantext.Database.Schema.Context
import
Gargantext.Database.Schema.Context
import
Gargantext.Prelude
hiding
(
sum
,
head
)
import
Gargantext.Prelude
hiding
(
sum
,
head
)
import
Opaleye
hiding
(
FromField
)
import
Opaleye
hiding
(
FromField
)
import
Prelude
hiding
(
null
,
id
,
map
,
sum
)
import
Prelude
hiding
(
null
,
id
,
map
,
sum
)
getContextWith
::
(
HasNodeError
err
,
JSONB
a
)
getContextWith
::
(
HasNodeError
err
,
JSONB
a
)
...
...
src/Gargantext/Database/Query/Table/Node/Children.hs
View file @
548c8d15
...
@@ -84,9 +84,9 @@ getChildrenNode pId _ maybeNodeType maybeOffset maybeLimit = do
...
@@ -84,9 +84,9 @@ getChildrenNode pId _ maybeNodeType maybeOffset maybeLimit = do
selectChildrenNode
::
HasDBid
NodeType
selectChildrenNode
::
HasDBid
NodeType
=>
ParentId
=>
ParentId
->
Maybe
NodeType
->
Maybe
NodeType
->
Select
NodeRead
->
Select
NodeRead
selectChildrenNode
parentId
maybeNodeType
=
proc
()
->
do
selectChildrenNode
parentId
maybeNodeType
=
proc
()
->
do
row
@
(
Node
_
_
typeName
_
parent_id
_
_
_
)
<-
queryNodeTable
-<
()
row
@
(
Node
_
_
typeName
_
parent_id
_
_
_
)
<-
queryNodeTable
-<
()
let
nodeType
=
maybe
0
toDBid
maybeNodeType
let
nodeType
=
maybe
0
toDBid
maybeNodeType
...
@@ -122,7 +122,7 @@ selectChildren' :: HasDBid NodeType
...
@@ -122,7 +122,7 @@ selectChildren' :: HasDBid NodeType
->
Select
ContextRead
->
Select
ContextRead
selectChildren'
parentId
maybeNodeType
=
proc
()
->
do
selectChildren'
parentId
maybeNodeType
=
proc
()
->
do
row
@
(
Context
cid
_
typeName
_
_
_
_
_
)
<-
queryContextTable
-<
()
row
@
(
Context
cid
_
typeName
_
_
_
_
_
)
<-
queryContextTable
-<
()
(
NodeContext
nid
cid'
_
_
)
<-
queryNodeContextTable
-<
()
(
NodeContext
_
nid
cid'
_
_
)
<-
queryNodeContextTable
-<
()
let
nodeType
=
maybe
0
toDBid
maybeNodeType
let
nodeType
=
maybe
0
toDBid
maybeNodeType
restrict
-<
typeName
.==
sqlInt4
nodeType
restrict
-<
typeName
.==
sqlInt4
nodeType
...
...
src/Gargantext/Database/Query/Table/NodeContext.hs
View file @
548c8d15
...
@@ -77,8 +77,9 @@ insertNodeContext ns = mkCmd $ \conn -> fromIntegral <$> (runInsert_ conn
...
@@ -77,8 +77,9 @@ insertNodeContext ns = mkCmd $ \conn -> fromIntegral <$> (runInsert_ conn
$
Insert
nodeContextTable
ns'
rCount
(
Just
DoNothing
))
$
Insert
nodeContextTable
ns'
rCount
(
Just
DoNothing
))
where
where
ns'
::
[
NodeContextWrite
]
ns'
::
[
NodeContextWrite
]
ns'
=
map
(
\
(
NodeContext
n
c
x
y
)
ns'
=
map
(
\
(
NodeContext
i
n
c
x
y
)
->
NodeContext
(
pgNodeId
n
)
->
NodeContext
(
sqlInt4
<$>
i
)
(
pgNodeId
n
)
(
pgNodeId
c
)
(
pgNodeId
c
)
(
sqlDouble
<$>
x
)
(
sqlDouble
<$>
x
)
(
sqlInt4
<$>
y
)
(
sqlInt4
<$>
y
)
...
@@ -93,7 +94,7 @@ deleteNodeContext :: Node_Id -> Context_Id -> Cmd err Int
...
@@ -93,7 +94,7 @@ deleteNodeContext :: Node_Id -> Context_Id -> Cmd err Int
deleteNodeContext
n
c
=
mkCmd
$
\
conn
->
deleteNodeContext
n
c
=
mkCmd
$
\
conn
->
fromIntegral
<$>
runDelete_
conn
fromIntegral
<$>
runDelete_
conn
(
Delete
nodeContextTable
(
Delete
nodeContextTable
(
\
(
NodeContext
n_id
c_id
_
_
)
->
n_id
.==
pgNodeId
n
(
\
(
NodeContext
_
n_id
c_id
_
_
)
->
n_id
.==
pgNodeId
n
.&&
c_id
.==
pgNodeId
c
.&&
c_id
.==
pgNodeId
c
)
)
rCount
rCount
...
...
src/Gargantext/Database/Query/Table/NodeContext_NodeContext.hs
0 → 100644
View file @
548c8d15
{-|
Module : Gargantext.Database.Select.Table.NodeContext_NodeContext
Description :
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
module
Gargantext.Database.Query.Table.NodeContext_NodeContext
(
module
Gargantext
.
Database
.
Schema
.
NodeContext_NodeContext
-- , query_NodeContext_NodeContext_Table
,
insertNodeContext_NodeContext
)
where
import
Data.Text
(
Text
)
import
Gargantext.Core.Types
import
Gargantext.Database.Prelude
import
Gargantext.Database.Schema.NodeContext_NodeContext
import
Gargantext.Database.Schema.Prelude
hiding
(
sum
)
import
Gargantext.Prelude
import
qualified
Database.PostgreSQL.Simple
as
PGS
{-
queryNodeContext_NodeContextTable :: Select NodeContext_NodeContextRead
queryNodeContext_NodeContextTable = selectTable nodeContext_NodeContextTable
-}
insertNodeContext_NodeContext
::
[(
CorpusId
,
DocId
,
AnnuaireId
,
ContactId
)]
->
Cmd
err
[
Int
]
insertNodeContext_NodeContext
contexts
=
do
let
fields
=
map
(
\
t
->
QualifiedIdentifier
Nothing
t
)
$
snd
fields_name
fields_name
::
(
[
Text
],
[
Text
])
fields_name
=
(
[
"corpus_id"
,
"doc_id"
,
"annuaire_id"
,
"contact_id"
]
,
[
"int4"
,
"int4"
,
"int4"
,
"int4"
]
)
result
<-
map
(
\
(
PGS
.
Only
a
)
->
a
)
<$>
runPGSQuery
queryInsert
(
PGS
.
Only
$
Values
fields
contexts
)
pure
[
sum
result
]
queryInsert
::
PGS
.
Query
queryInsert
=
[
sql
|
WITH input(corpus_id, doc_id, annuaire_id, contact_id) AS (?)
INSERT into nodescontexts_nodescontexts (nodescontexts1, nodescontexts2)
SELECT context1.id, context2.id FROM input
INNER JOIN nodes_contexts context1 ON context1.node_id = input.corpus_id
INNER JOIN nodes_contexts context2 ON context2.node_id = input.annuaire_id
WHERE context1.context_id = input.doc_id
AND context2.context_id = input.contact_id
ON CONFLICT (nodescontexts1, nodescontexts2) DO Nothing
RETURNING 1
|]
src/Gargantext/Database/Schema/NodeContext.hs
View file @
548c8d15
...
@@ -26,29 +26,33 @@ import Gargantext.Database.Schema.NodeNode () -- Just importing some instances
...
@@ -26,29 +26,33 @@ import Gargantext.Database.Schema.NodeNode () -- Just importing some instances
import
Gargantext.Prelude
import
Gargantext.Prelude
data
NodeContextPoly
node_id
context_id
score
cat
data
NodeContextPoly
id
node_id
context_id
score
cat
=
NodeContext
{
_nc_node_id
::
!
node_id
=
NodeContext
{
_nc_id
::
!
id
,
_nc_node_id
::
!
node_id
,
_nc_context_id
::
!
context_id
,
_nc_context_id
::
!
context_id
,
_nc_score
::
!
score
,
_nc_score
::
!
score
,
_nc_category
::
!
cat
,
_nc_category
::
!
cat
}
deriving
(
Show
)
}
deriving
(
Show
)
type
NodeContextWrite
=
NodeContextPoly
(
Column
(
SqlInt4
))
type
NodeContextWrite
=
NodeContextPoly
(
Maybe
(
Column
(
SqlInt4
)))
(
Column
(
SqlInt4
))
(
Column
(
SqlInt4
))
(
Maybe
(
Column
(
SqlFloat8
)))
(
Column
(
SqlInt4
))
(
Maybe
(
Column
(
SqlInt4
)))
(
Maybe
(
Column
(
SqlFloat8
)))
(
Maybe
(
Column
(
SqlInt4
)))
type
NodeContextRead
=
NodeContextPoly
(
Column
(
SqlInt4
))
type
NodeContextRead
=
NodeContextPoly
(
Column
(
SqlInt4
))
(
Column
(
SqlInt4
))
(
Column
(
SqlInt4
))
(
Column
(
SqlFloat8
))
(
Column
(
SqlInt4
))
(
Column
(
SqlInt4
))
(
Column
(
SqlFloat8
))
(
Column
(
SqlInt4
))
type
NodeContextReadNull
=
NodeContextPoly
(
Column
(
Nullable
SqlInt4
))
type
NodeContextReadNull
=
NodeContextPoly
(
Column
(
Nullable
SqlInt4
))
(
Column
(
Nullable
SqlInt4
))
(
Column
(
Nullable
SqlInt4
))
(
Column
(
Nullable
SqlFloat8
))
(
Column
(
Nullable
SqlInt4
))
(
Column
(
Nullable
SqlInt4
))
(
Column
(
Nullable
SqlFloat8
))
(
Column
(
Nullable
SqlInt4
))
type
NodeContext
=
NodeContextPoly
NodeId
NodeId
(
Maybe
Double
)
(
Maybe
Int
)
type
NodeContext
=
NodeContextPoly
(
Maybe
Int
)
NodeId
NodeId
(
Maybe
Double
)
(
Maybe
Int
)
$
(
makeAdaptorAndInstance
"pNodeContext"
''
N
odeContextPoly
)
$
(
makeAdaptorAndInstance
"pNodeContext"
''
N
odeContextPoly
)
makeLenses
''
N
odeContextPoly
makeLenses
''
N
odeContextPoly
...
@@ -57,7 +61,8 @@ nodeContextTable :: Table NodeContextWrite NodeContextRead
...
@@ -57,7 +61,8 @@ nodeContextTable :: Table NodeContextWrite NodeContextRead
nodeContextTable
=
nodeContextTable
=
Table
"nodes_contexts"
Table
"nodes_contexts"
(
pNodeContext
(
pNodeContext
NodeContext
{
_nc_node_id
=
requiredTableField
"node_id"
NodeContext
{
_nc_id
=
optionalTableField
"id"
,
_nc_node_id
=
requiredTableField
"node_id"
,
_nc_context_id
=
requiredTableField
"context_id"
,
_nc_context_id
=
requiredTableField
"context_id"
,
_nc_score
=
optionalTableField
"score"
,
_nc_score
=
optionalTableField
"score"
,
_nc_category
=
optionalTableField
"category"
,
_nc_category
=
optionalTableField
"category"
...
...
src/Gargantext/Database/Schema/NodeContext_NodeContext.hs
0 → 100644
View file @
548c8d15
{-|
Module : Gargantext.Database.Schema.ContextContext
Description :
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
module
Gargantext.Database.Schema.NodeContext_NodeContext
where
import
Gargantext.Core.Types
import
Gargantext.Database.Schema.Prelude
import
Gargantext.Prelude
data
NodeContext_NodeContextPoly
nodecontext1
nodecontext2
=
NodeContext_NodeContext
{
_ncnc_nodecontext1
::
!
nodecontext1
,
_ncnc_nodecontext2
::
!
nodecontext2
}
deriving
(
Show
)
type
NodeContext_NodeContextWrite
=
NodeContext_NodeContextPoly
(
Column
(
SqlInt4
))
(
Column
(
SqlInt4
))
type
NodeContext_NodeContextRead
=
NodeContext_NodeContextPoly
(
Column
(
SqlInt4
))
(
Column
(
SqlInt4
))
type
NodeContext_NodeContextReadNull
=
NodeContext_NodeContextPoly
(
Column
(
Nullable
SqlInt4
))
(
Column
(
Nullable
SqlInt4
))
type
NodeContext_NodeContext
=
NodeContext_NodeContextPoly
NodeContextId
NodeContextId
$
(
makeAdaptorAndInstance
"pNodeContext_NodeContext"
''
N
odeContext_NodeContextPoly
)
makeLenses
''
N
odeContext_NodeContextPoly
nodeContext_NodeContextTable
::
Table
NodeContext_NodeContextWrite
NodeContext_NodeContextRead
nodeContext_NodeContextTable
=
Table
"nodescontexts_nodescontexts"
(
pNodeContext_NodeContext
NodeContext_NodeContext
{
_ncnc_nodecontext1
=
requiredTableField
"nodescontexts1"
,
_ncnc_nodecontext2
=
requiredTableField
"nodescontexts2"
}
)
queryNodeContext_NodeContextTable
::
Query
NodeContext_NodeContextRead
queryNodeContext_NodeContextTable
=
selectTable
nodeContext_NodeContextTable
src/Gargantext/Database/Schema/NodeNode.hs
View file @
548c8d15
...
@@ -11,8 +11,6 @@ Here is a longer description of this module, containing some
...
@@ -11,8 +11,6 @@ Here is a longer description of this module, containing some
commentary with @some markup@.
commentary with @some markup@.
-}
-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE QuasiQuotes #-}
...
@@ -63,18 +61,3 @@ nodeNodeTable =
...
@@ -63,18 +61,3 @@ nodeNodeTable =
}
}
)
)
instance
DefaultFromField
(
Nullable
SqlInt4
)
Int
where
defaultFromField
=
fromPGSFromField
instance
DefaultFromField
(
Nullable
SqlFloat8
)
Int
where
defaultFromField
=
fromPGSFromField
instance
DefaultFromField
(
Nullable
SqlFloat8
)
Double
where
defaultFromField
=
fromPGSFromField
instance
DefaultFromField
SqlFloat8
(
Maybe
Double
)
where
defaultFromField
=
fromPGSFromField
instance
DefaultFromField
SqlInt4
(
Maybe
Int
)
where
defaultFromField
=
fromPGSFromField
src/Gargantext/Database/Types.hs
View file @
548c8d15
...
@@ -9,6 +9,7 @@ Portability : POSIX
...
@@ -9,6 +9,7 @@ Portability : POSIX
-}
-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TemplateHaskell #-}
module
Gargantext.Database.Types
module
Gargantext.Database.Types
...
@@ -40,3 +41,19 @@ instance HasText a => HasText (Indexed i a)
...
@@ -40,3 +41,19 @@ instance HasText a => HasText (Indexed i a)
hasText
(
Indexed
_
a
)
=
hasText
a
hasText
(
Indexed
_
a
)
=
hasText
a
instance
(
Hashable
a
,
Hashable
b
)
=>
Hashable
(
Indexed
a
b
)
instance
(
Hashable
a
,
Hashable
b
)
=>
Hashable
(
Indexed
a
b
)
instance
DefaultFromField
(
Nullable
SqlInt4
)
Int
where
defaultFromField
=
fromPGSFromField
instance
DefaultFromField
(
Nullable
SqlFloat8
)
Int
where
defaultFromField
=
fromPGSFromField
instance
DefaultFromField
(
Nullable
SqlFloat8
)
Double
where
defaultFromField
=
fromPGSFromField
instance
DefaultFromField
SqlFloat8
(
Maybe
Double
)
where
defaultFromField
=
fromPGSFromField
instance
DefaultFromField
SqlInt4
(
Maybe
Int
)
where
defaultFromField
=
fromPGSFromField
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