Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
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
Przemyslaw Kaminski
haskell-gargantext
Commits
0b956a2e
Commit
0b956a2e
authored
Nov 21, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] group result of SQL result.
parent
6fcad8ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
9 deletions
+14
-9
Ngrams.hs
src/Gargantext/Database/Ngrams.hs
+14
-9
No files found.
src/Gargantext/Database/Ngrams.hs
View file @
0b956a2e
...
@@ -34,6 +34,8 @@ import Database.PostgreSQL.Simple.ToField (toField)
...
@@ -34,6 +34,8 @@ import Database.PostgreSQL.Simple.ToField (toField)
import
Database.PostgreSQL.Simple.ToRow
(
toRow
)
import
Database.PostgreSQL.Simple.ToRow
(
toRow
)
import
Database.PostgreSQL.Simple.Types
(
Values
(
..
),
QualifiedIdentifier
(
..
))
import
Database.PostgreSQL.Simple.Types
(
Values
(
..
),
QualifiedIdentifier
(
..
))
import
GHC.Generics
(
Generic
)
import
GHC.Generics
(
Generic
)
import
Gargantext.Database.Config
(
nodeTypeId
)
import
Gargantext.Database.Types.Node
(
NodeType
)
import
Gargantext.Database.Node
(
mkCmd
,
Cmd
(
..
))
import
Gargantext.Database.Node
(
mkCmd
,
Cmd
(
..
))
import
Gargantext.Prelude
import
Gargantext.Prelude
import
qualified
Database.PostgreSQL.Simple
as
DPS
import
qualified
Database.PostgreSQL.Simple
as
DPS
...
@@ -176,10 +178,8 @@ queryInsertNgrams = [sql|
...
@@ -176,10 +178,8 @@ queryInsertNgrams = [sql|
-- | Ngrams Table
-- | Ngrams Table
data
NgramsTableParam
=
data
NgramsTableParam
=
NgramsTableParam
{
_nt_listId
::
Int
NgramsTableParam
{
_nt_listId
::
Int
,
_nt_corpusId
::
Int
,
_nt_corpusId
::
Int
,
_nt_typeNode
::
Int
,
_nt_typeNgrams
::
Int
}
}
type
NgramsTableParamUser
=
NgramsTableParam
type
NgramsTableParamUser
=
NgramsTableParam
...
@@ -191,9 +191,13 @@ data NgramsTableData = NgramsTableData { _ntd_terms :: Text
...
@@ -191,9 +191,13 @@ data NgramsTableData = NgramsTableData { _ntd_terms :: Text
,
_ntd_weight
::
Double
,
_ntd_weight
::
Double
}
deriving
(
Show
)
}
deriving
(
Show
)
getTableNgrams
::
NgramsTableParamUser
->
NgramsTableParamMaster
->
Cmd
[(
Text
,
Int
,
Int
,
Double
)]
getTableNgrams
::
NodeType
->
NgramsType
->
NgramsTableParamUser
->
NgramsTableParamMaster
->
Cmd
[(
Text
,
Int
,
Int
,
Double
)]
getTableNgrams
(
NgramsTableParam
ul
uc
utn
utg
)
(
NgramsTableParam
ml
mc
mtn
mtg
)
=
getTableNgrams
nodeT
ngrmT
(
NgramsTableParam
ul
uc
)
(
NgramsTableParam
ml
mc
)
=
mkCmd
$
\
conn
->
DPS
.
query
conn
querySelectTableNgrams
(
ul
,
uc
,
utn
,
utg
,
ml
,
mc
,
mtn
,
mtg
)
mkCmd
$
\
conn
->
DPS
.
query
conn
querySelectTableNgrams
(
ul
,
uc
,
nodeTId
,
ngrmTId
,
ml
,
mc
,
nodeTId
,
ngrmTId
)
where
nodeTId
=
nodeTypeId
nodeT
ngrmTId
=
ngramsTypeId
ngrmT
querySelectTableNgrams
::
DPS
.
Query
querySelectTableNgrams
::
DPS
.
Query
...
@@ -220,8 +224,9 @@ querySelectTableNgrams = [sql|
...
@@ -220,8 +224,9 @@ querySelectTableNgrams = [sql|
SELECT COALESCE(tu.terms,tm.terms) AS terms
SELECT COALESCE(tu.terms,tm.terms) AS terms
, COALESCE(tu.n,tm.n) AS n
, COALESCE(tu.n,tm.n) AS n
, COALESCE(tu.ngrams_type,tm.ngrams_type) AS ngrams_type
, COALESCE(tu.ngrams_type,tm.ngrams_type) AS ngrams_type
, COALESCE(tu.weight,tm.weight) AS weight
, SUM(COALESCE(tu.weight,tm.weight)) AS weight
FROM tableUser tu RIGHT JOIN tableMaster tm ON tu.terms = tm.terms;
FROM tableUser tu RIGHT JOIN tableMaster tm ON tu.terms = tm.terms
GROUP BY tu.terms,tm.terms,tu.n,tm.n,tu.ngrams_type,tm.ngrams_type;
|]
|]
...
...
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