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
9
Merge Requests
9
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
d5b62df5
Commit
d5b62df5
authored
Feb 15, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] Get default lists of userMaster.
parent
4a7eac85
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
6 deletions
+75
-6
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+10
-6
Lists.hs
src/Gargantext/Database/Lists.hs
+65
-0
No files found.
src/Gargantext/API/Ngrams.hs
View file @
d5b62df5
...
...
@@ -34,7 +34,7 @@ add get
module
Gargantext.API.Ngrams
where
--
import Debug.Trace (trace)
import
Debug.Trace
(
trace
)
import
Prelude
(
Enum
,
Bounded
,
Semigroup
(
..
),
minBound
,
maxBound
{-, round-}
,
error
)
-- import Gargantext.Database.Schema.User (UserId)
import
Data.Functor
((
$>
))
...
...
@@ -47,7 +47,7 @@ import Data.Monoid
--import Data.Semigroup
import
Data.Set
(
Set
)
-- import qualified Data.List as List
-- import Data.Maybe (isJust
)
import
Data.Maybe
(
catMaybes
)
-- import Data.Tuple.Extra (first)
import
qualified
Data.Map.Strict
as
Map
import
Data.Map.Strict
(
Map
)
...
...
@@ -70,8 +70,11 @@ import Data.Validity
import
GHC.Generics
(
Generic
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
-- import Gargantext.Database.Schema.Ngrams (NgramsTypeId, ngramsTypeId, NgramsTableData(..))
import
Gargantext.Database.Config
(
userMaster
)
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
)
import
Gargantext.Database.Utils
(
fromField'
)
import
Gargantext.Database.Utils
(
fromField'
,
HasConnection
)
import
Gargantext.Database.Lists
(
listsWith
)
import
Gargantext.Database.Schema.Node
(
HasNodeError
)
import
Database.PostgreSQL.Simple.FromField
(
FromField
,
fromField
)
import
qualified
Gargantext.Database.Schema.Ngrams
as
Ngrams
-- import Gargantext.Database.Schema.NodeNgram hiding (Action)
...
...
@@ -744,7 +747,7 @@ getListNgrams nodeIds ngramsType = do
-- | TODO Errors management
-- TODO: polymorphic for Annuaire or Corpus or ...
-- | Table of Ngrams is a ListNgrams formatted (sorted and/or cut).
getTableNgrams
::
RepoCmdM
env
err
m
getTableNgrams
::
(
RepoCmdM
env
err
m
,
HasNodeError
err
,
HasConnection
env
)
=>
CorpusId
->
Maybe
TabType
->
[
ListId
]
->
Maybe
Limit
->
Maybe
Offset
-- -> Maybe MinSize -> Maybe MaxSize
...
...
@@ -758,7 +761,8 @@ getTableNgrams _cId maybeTabType listIds mlimit moffset = do
defaultLimit
=
10
-- TODO
limit_
=
maybe
defaultLimit
identity
mlimit
offset_
=
maybe
0
identity
moffset
getListNgrams
([
104
]
<>
listIds
)
ngramsType
lists
<-
catMaybes
<$>
listsWith
userMaster
trace
(
show
lists
)
$
getListNgrams
(
lists
<>
listIds
)
ngramsType
&
mapped
.
v_data
.
_NgramsTable
%~
(
take
limit_
.
drop
offset_
)
src/Gargantext/Database/Lists.hs
0 → 100644
View file @
d5b62df5
{-|
Module : Gargantext.Database.Lists
Description : Main requests of Node to the database
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE Arrows #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}
module
Gargantext.Database.Lists
where
import
Control.Arrow
(
returnA
)
import
Gargantext.Core.Types
-- (NodePoly(..), NodeCorpus, ListId)
import
Gargantext.Core.Types.Individu
(
Username
)
import
Gargantext.Database.Config
(
nodeTypeId
)
import
Gargantext.Database.Schema.Node
-- (HasNodeError, queryNodeTable)
import
Gargantext.Database.Schema.User
-- (queryUserTable)
import
Gargantext.Database.Utils
import
Gargantext.Prelude
hiding
(
sum
,
head
)
import
Opaleye
hiding
(
FromField
)
import
Opaleye.Internal.QueryArr
(
Query
)
import
Prelude
hiding
(
null
,
id
,
map
,
sum
)
-- | To get all lists of a user
-- /!\ lists of different types of corpora (Annuaire or Documents)
listsWith
::
HasNodeError
err
=>
Username
->
Cmd
err
[
Maybe
ListId
]
listsWith
u
=
runOpaQuery
(
selectLists
u
)
where
selectLists
u
=
proc
()
->
do
(
auth_user
,
nodes
)
<-
listsWithJoin2
-<
()
restrict
-<
user_username
auth_user
.==
(
pgStrictText
u
)
restrict
-<
_node_typename
nodes
.==
(
toNullable
$
pgInt4
$
nodeTypeId
NodeList
)
returnA
-<
_node_id
nodes
listsWithJoin2
::
Query
(
UserRead
,
NodeReadNull
)
listsWithJoin2
=
leftJoin
queryUserTable
queryNodeTable
cond12
where
cond12
(
u
,
n
)
=
user_id
u
.==
_node_userId
n
{-
listsWithJoin3 :: Query (NodeRead, (UserRead, NodeReadNull))
listsWithJoin3 = leftJoin3 queryUserTable queryNodeTable queryNodeTable cond12 cond23
where
cond12 :: (NodeRead
cond12 (u,n) = user_id u .== _node_userId n
cond23 :: (NodeRead, (UserRead, NodeReadNull)) -> Column PGBool
cond23 (n1,(u,n2)) = (toNullable $ _node_id n1) .== _node_parentId n2
--}
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