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
10
Merge Requests
10
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
20d568ee
Commit
20d568ee
authored
Dec 01, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] masterListId bug, make it simple finally.
parent
c2bfe19e
Pipeline
#36
failed with stage
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
38 deletions
+45
-38
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+3
-13
Node.hs
src/Gargantext/API/Node.hs
+2
-2
Main.hs
src/Gargantext/Core/Types/Main.hs
+2
-0
Ngrams.hs
src/Gargantext/Database/Ngrams.hs
+31
-20
Node.hs
src/Gargantext/Database/Node.hs
+4
-2
NodeNode.hs
src/Gargantext/Database/NodeNode.hs
+2
-1
Flow.hs
src/Gargantext/Text/Flow.hs
+1
-0
No files found.
src/Gargantext/API/Ngrams.hs
View file @
20d568ee
...
...
@@ -44,7 +44,7 @@ import qualified Data.Set as Set
--import Data.Maybe (catMaybes)
--import qualified Data.Map.Strict as DM
--import qualified Data.Set as Set
import
Control.Lens
(
view
,
(
.~
))
import
Control.Lens
((
.~
))
import
Data.Aeson
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Either
(
Either
(
Left
))
...
...
@@ -54,14 +54,12 @@ import Data.Swagger
import
Data.Text
(
Text
)
import
Database.PostgreSQL.Simple
(
Connection
)
import
GHC.Generics
(
Generic
)
import
Gargantext.Core.Types
(
node_id
)
--import Gargantext.Core.Types.Main (Tree(..))
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
import
Gargantext.Database.Types.Node
(
NodeType
(
..
))
import
Gargantext.Database.Node
(
getListsWithParentId
)
import
qualified
Gargantext.Database.Ngrams
as
Ngrams
import
Gargantext.Prelude
import
Gargantext.Core.Types
(
ListType
(
..
),
ListId
)
import
Gargantext.Core.Types
(
ListType
(
..
),
ListId
,
CorpusId
)
import
Prelude
(
Enum
,
Bounded
,
minBound
,
maxBound
)
import
Servant
hiding
(
Patch
)
import
Test.QuickCheck
(
elements
)
...
...
@@ -236,7 +234,6 @@ ngramsIdPatch = fromList $ catMaybes $ reverse [ replace (1::NgramsId) (Just $ n
------------------------------------------------------------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
type
CorpusId
=
Int
type
TableNgramsApiGet
=
Summary
" Table Ngrams API Get"
:>
QueryParam
"ngramsType"
TabType
...
...
@@ -252,13 +249,6 @@ type NgramsIdPatchsFeed = NgramsIdPatchs
type
NgramsIdPatchsBack
=
NgramsIdPatchs
defaultList
::
Connection
->
CorpusId
->
IO
ListId
defaultList
c
cId
=
view
node_id
<$>
maybe
(
panic
noListFound
)
identity
<$>
head
<$>
getListsWithParentId
c
cId
where
noListFound
=
"Gargantext.API.Ngrams.defaultList: no list found"
{-
toLists :: ListId -> NgramsIdPatchs -> [(ListId, NgramsId, ListTypeId)]
-- toLists = undefined
...
...
@@ -305,7 +295,7 @@ getTableNgrams c cId maybeTabType maybeListId = do
_
->
panic
$
lieu
<>
"No Ngrams for this tab"
listId
<-
case
maybeListId
of
Nothing
->
defaultList
c
cId
Nothing
->
Ngrams
.
defaultList
c
cId
Just
lId
->
pure
lId
(
ngramsTableDatas
,
mapToParent
,
mapToChildren
)
<-
...
...
src/Gargantext/API/Node.hs
View file @
20d568ee
...
...
@@ -53,7 +53,7 @@ import Gargantext.Prelude
import
Gargantext.Database.Types.Node
import
Gargantext.Database.Node
(
runCmd
,
getNodesWithParentId
,
getNode
,
getNodesWith
,
CorpusId
,
getNode
,
getNodesWith
,
deleteNode
,
deleteNodes
,
mk
,
JSONB
)
import
qualified
Gargantext.Database.Node.Update
as
U
(
update
,
Update
(
..
))
import
Gargantext.Database.Facet
(
FacetDoc
,
runViewDocuments'
,
OrderBy
(
..
)
...
...
@@ -65,7 +65,7 @@ import Gargantext.Database.NodeNode (nodesToFavorite, nodesToTrash)
import
Gargantext.Viz.Graph
(
Graph
,
readGraphFromJson
,
defaultGraph
)
-- import Gargantext.Core (Lang(..))
import
Gargantext.Core.Types
(
Offset
,
Limit
)
import
Gargantext.Core.Types.Main
(
Tree
,
NodeTree
,
ListId
)
import
Gargantext.Core.Types.Main
(
Tree
,
NodeTree
,
ListId
,
CorpusId
)
-- import Gargantext.Text.Terms (TermType(..))
import
Test.QuickCheck
(
elements
)
...
...
src/Gargantext/Core/Types/Main.hs
View file @
20d568ee
...
...
@@ -81,6 +81,8 @@ corpusTree nId t = TreeN (NodeTree ("Corpus " <> t) NodeCorpus nId) ( [ leafT
--data Classification = Favorites | MyClassifcation
type
CorpusId
=
Int
type
ListId
=
Int
-- TODO multiple ListType declaration, remove it
...
...
src/Gargantext/Database/Ngrams.hs
View file @
20d568ee
...
...
@@ -23,28 +23,27 @@ Ngrams connection to the Database.
module
Gargantext.Database.Ngrams
where
import
Prelude
(
Enum
,
Bounded
,
minBound
,
maxBound
)
import
Control.Lens
(
makeLenses
,
view
)
import
Data.ByteString.Internal
(
ByteString
)
import
Data.Map
(
Map
,
fromList
,
lookup
,
fromListWith
)
import
Data.Set
(
Set
)
import
Data.Tuple.Extra
(
both
)
import
qualified
Data.Set
as
DS
import
Data.Text
(
Text
,
splitOn
)
import
Database.PostgreSQL.Simple.FromRow
(
fromRow
,
field
)
import
Database.PostgreSQL.Simple.SqlQQ
(
sql
)
import
Database.PostgreSQL.Simple.ToField
(
toField
)
import
Database.PostgreSQL.Simple.ToRow
(
toRow
)
import
Database.PostgreSQL.Simple.Types
(
Values
(
..
),
QualifiedIdentifier
(
..
))
import
Debug.Trace
(
trace
)
import
GHC.Generics
(
Generic
)
import
Gargantext.Core.Types
-- (fromListTypeId, ListType, NodePoly(Node))
import
Gargantext.Database.Config
(
nodeTypeId
,
userMaster
)
import
Gargantext.Database.Types.Node
(
NodeType
)
import
Gargantext.Database.Node
(
mkCmd
,
Cmd
(
..
))
import
Gargantext.Database.Node
(
mkCmd
,
Cmd
(
..
),
getListsWithParentId
,
getCorporaWithParentId
)
import
Gargantext.Database.Root
(
getRoot
)
import
Gargantext.
Database.Tree
(
dbTree
,
toNodeTree
)
import
Gargantext.
Core.Types.Main
(
NodeTree
(
..
)
)
import
Gargantext.
Core.Types
(
CorpusId
)
import
Gargantext.
Database.Types.Node
(
NodeType
)
import
Gargantext.Prelude
import
Prelude
(
Enum
,
Bounded
,
minBound
,
maxBound
)
import
qualified
Data.Set
as
DS
import
qualified
Database.PostgreSQL.Simple
as
DPS
--data NgramPoly id terms n = NgramDb { ngram_id :: id
...
...
@@ -181,7 +180,12 @@ queryInsertNgrams = [sql|
JOIN ngrams c USING (terms); -- columns of unique index
|]
defaultList
::
DPS
.
Connection
->
CorpusId
->
IO
ListId
defaultList
c
cId
=
view
node_id
<$>
maybe
(
panic
errMessage
)
identity
<$>
head
<$>
getListsWithParentId
c
cId
where
errMessage
=
"Gargantext.API.Ngrams.defaultList: no list found"
-- | Ngrams Table
-- TODO: the way we are getting main Master Corpus and List ID is not clean
...
...
@@ -192,15 +196,19 @@ getNgramsTableDb :: DPS.Connection
->
NgramsTableParamUser
->
IO
([
NgramsTableData
],
MapToParent
,
MapToChildren
)
getNgramsTableDb
c
nt
ngrt
ntp
@
(
NgramsTableParam
listIdUser
_
)
=
do
let
lieu
=
"Garg.Db.Ngrams.getTableNgrams: "
maybeRoot
<-
head
<$>
getRoot
userMaster
c
let
masterRootId
=
maybe
(
panic
$
lieu
<>
"no userMaster Tree"
)
(
view
node_id
)
maybeRoot
tree
<-
map
toNodeTree
<$>
dbTree
c
masterRootId
let
maybeCorpus
=
head
$
filter
(
\
n
->
_nt_type
n
==
NodeCorpus
)
tree
let
maybeList
=
head
$
filter
(
\
n
->
_nt_type
n
==
NodeList
)
tree
let
maybeIds
=
fmap
(
both
_nt_id
)
$
(,)
<$>
maybeCorpus
<*>
maybeList
let
(
corpusMasterId
,
listMasterId
)
=
maybe
(
panic
$
lieu
<>
"no CorpusId or ListId"
)
identity
maybeIds
let
path
=
"Garg.Db.Ngrams.getTableNgrams: "
let
masterRootId
=
maybe
(
panic
$
path
<>
"no userMaster Tree"
)
(
view
node_id
)
maybeRoot
-- let errMess = panic "Error"
corpusMasterId
<-
maybe
(
panic
"error corpus master"
)
(
view
node_id
)
<$>
head
<$>
getCorporaWithParentId
c
masterRootId
listMasterId
<-
maybe
(
panic
"error liste master"
)
(
view
node_id
)
<$>
head
<$>
getListsWithParentId
c
corpusMasterId
ngramsTableData
<-
getNgramsTableData
c
nt
ngrt
ntp
(
NgramsTableParam
listMasterId
corpusMasterId
)
(
mapToParent
,
mapToChildren
)
<-
getNgramsGroup
c
listIdUser
listMasterId
pure
(
ngramsTableData
,
mapToParent
,
mapToChildren
)
...
...
@@ -224,11 +232,14 @@ getNgramsTableData :: DPS.Connection
->
NgramsTableParamUser
->
NgramsTableParamMaster
->
IO
[
NgramsTableData
]
getNgramsTableData
conn
nodeT
ngrmT
(
NgramsTableParam
ul
uc
)
(
NgramsTableParam
ml
mc
)
=
map
(
\
(
t
,
n
,
nt
,
w
)
->
NgramsTableData
t
n
(
fromListTypeId
nt
)
w
)
<$>
DPS
.
query
conn
querySelectTableNgrams
(
ul
,
uc
,
nodeTId
,
ngrmTId
,
ml
,
mc
,
nodeTId
,
ngrmTId
,
uc
)
where
nodeTId
=
nodeTypeId
nodeT
ngrmTId
=
ngramsTypeId
ngrmT
trace
(
"Ngrams table params"
<>
show
params
)
<$>
map
(
\
(
t
,
n
,
nt
,
w
)
->
NgramsTableData
t
n
(
fromListTypeId
nt
)
w
)
<$>
DPS
.
query
conn
querySelectTableNgrams
params
where
nodeTId
=
nodeTypeId
nodeT
ngrmTId
=
ngramsTypeId
ngrmT
params
=
(
ul
,
uc
,
nodeTId
,
ngrmTId
,
ml
,
mc
,
nodeTId
,
ngrmTId
,
uc
)
querySelectTableNgrams
::
DPS
.
Query
...
...
src/Gargantext/Database/Node.hs
View file @
20d568ee
...
...
@@ -18,7 +18,7 @@ Portability : POSIX
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedStrings
#-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE TemplateHaskell #-}
...
...
@@ -84,7 +84,6 @@ mkCmd :: (Connection -> IO a) -> Cmd a
mkCmd
=
Cmd
.
ReaderT
------------------------------------------------------------------------
type
CorpusId
=
Int
type
AnnuaireId
=
Int
type
DocId
=
Int
...
...
@@ -276,6 +275,9 @@ getDocumentsWithParentId conn n = runQuery conn $ selectNodesWith' n (Just NodeD
getListsWithParentId
::
Connection
->
Int
->
IO
[
Node
HyperdataList
]
getListsWithParentId
conn
n
=
runQuery
conn
$
selectNodesWith'
n
(
Just
NodeList
)
getCorporaWithParentId
::
Connection
->
Int
->
IO
[
Node
HyperdataCorpus
]
getCorporaWithParentId
conn
n
=
runQuery
conn
$
selectNodesWith'
n
(
Just
NodeCorpus
)
------------------------------------------------------------------------
selectNodesWithParentID
::
Int
->
Query
NodeRead
selectNodesWithParentID
n
=
proc
()
->
do
...
...
src/Gargantext/Database/NodeNode.hs
View file @
20d568ee
...
...
@@ -30,7 +30,8 @@ import Database.PostgreSQL.Simple.SqlQQ (sql)
import
Control.Lens.TH
(
makeLensesWith
,
abbreviatedFields
)
import
Data.Maybe
(
Maybe
)
import
Data.Profunctor.Product.TH
(
makeAdaptorAndInstance
)
import
Gargantext.Database.Node
(
Cmd
(
..
),
mkCmd
,
CorpusId
,
DocId
)
import
Gargantext.Database.Node
(
Cmd
(
..
),
mkCmd
,
DocId
)
import
Gargantext.Core.Types
(
CorpusId
)
import
Gargantext.Prelude
import
Opaleye
...
...
src/Gargantext/Text/Flow.hs
View file @
20d568ee
...
...
@@ -42,6 +42,7 @@ import Gargantext.Text.Metrics.Count (cooc)
import
Gargantext.Text.Metrics
(
filterCooc
,
FilterConfig
(
..
),
Clusters
(
..
),
SampleBins
(
..
),
DefaultValue
(
..
),
MapListSize
(
..
),
InclusionSize
(
..
))
import
Gargantext.Text.Terms
(
TermType
,
extractTerms
)
import
Gargantext.Text.Context
(
splitBy
,
SplitContext
(
Sentences
))
import
Gargantext.Core.Types
(
CorpusId
)
import
Gargantext.Text.Parsers.CSV
...
...
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