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
159
Issues
159
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
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
f28cd643
Commit
f28cd643
authored
Oct 07, 2024
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused functions from Gargantext.Database.Query.Table.Node
parent
ab0a0edf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
87 deletions
+1
-87
Node.hs
src/Gargantext/Database/Query/Table/Node.hs
+1
-87
No files found.
src/Gargantext/Database/Query/Table/Node.hs
View file @
f28cd643
...
...
@@ -15,12 +15,11 @@ Portability : POSIX
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
module
Gargantext.Database.Query.Table.Node
(
-- * Smart constructors, classes, defaults and helper functions
defaultList
,
MkCorpus
(
..
)
,
CorpusType
(
..
)
,
node
,
queryNodeSearchTable
...
...
@@ -65,13 +64,10 @@ import Database.PostgreSQL.Simple.SqlQQ (sql)
import
Gargantext.Core
(
HasDBid
(
toDBid
)
)
import
Gargantext.Core.Types
import
Gargantext.Core.Types.Query
(
Limit
,
Offset
)
import
Gargantext.Database.Admin.Types.Hyperdata.Any
(
HyperdataAny
)
import
Gargantext.Database.Admin.Types.Hyperdata.Corpus
(
HyperdataAnnuaire
,
HyperdataCorpus
)
import
Gargantext.Database.Admin.Types.Hyperdata.Default
(
defaultHyperdata
,
DefaultHyperdata
(
..
)
)
import
Gargantext.Database.Admin.Types.Hyperdata.Document
(
HyperdataDocument
,
HyperdataDocumentV3
)
import
Gargantext.Database.Admin.Types.Hyperdata.Folder
(
HyperdataFolder
)
import
Gargantext.Database.Admin.Types.Hyperdata.List
(
HyperdataList
)
import
Gargantext.Database.Admin.Types.Hyperdata.Model
(
HyperdataModel
)
import
Gargantext.Database.Admin.Types.Hyperdata.Prelude
(
Hyperdata
)
import
Gargantext.Database.Prelude
(
DBCmd
,
JSONB
,
mkCmd
,
runPGSQuery
,
runOpaQuery
)
import
Gargantext.Database.Query.Filter
(
limit'
,
offset'
)
...
...
@@ -91,10 +87,6 @@ selectNode id' = proc () -> do
restrict
-<
_node_id
row
.==
id'
returnA
-<
row
runGetNodes
::
Select
NodeRead
->
DBCmd
err
[
Node
HyperdataAny
]
runGetNodes
=
runOpaQuery
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | order by publication date
-- Favorites (Bool), node_ngrams
...
...
@@ -155,21 +147,6 @@ getNodesWithParentId n = runOpaQuery $ selectNodesWithParentID n'
Just
n''
->
n''
Nothing
->
0
-- | Given a node id, find it's parent node id (if exists)
getParentId
::
NodeId
->
DBCmd
err
(
Maybe
NodeId
)
getParentId
nId
=
do
result
<-
runPGSQuery
query
(
PGS
.
Only
nId
)
case
result
of
[
PGS
.
Only
parentId
]
->
pure
$
Just
$
UnsafeMkNodeId
parentId
_
->
pure
Nothing
where
query
::
PGS
.
Query
query
=
[
sql
|
SELECT parent_id
FROM nodes
WHERE id = ?;
|]
-- | Given a node id, find it's closest parent of given type
-- NOTE: This isn't too optimal: can make successive queries depending on how
-- deeply nested the child is.
...
...
@@ -248,16 +225,6 @@ getClosestChildrenByType nId nType = do
|]
------------------------------------------------------------------------
getDocumentsV3WithParentId
::
HasDBid
NodeType
=>
NodeId
->
DBCmd
err
[
Node
HyperdataDocumentV3
]
getDocumentsV3WithParentId
n
=
runOpaQuery
$
selectNodesWith'
n
(
Just
NodeDocument
)
-- TODO: merge with getDocumentsWithParentId by having a class IsHyperdataDocument
getDocumentsWithParentId
::
HasDBid
NodeType
=>
NodeId
->
DBCmd
err
[
Node
HyperdataDocument
]
getDocumentsWithParentId
n
=
runOpaQuery
$
selectNodesWith'
n
(
Just
NodeDocument
)
getListsModelWithParentId
::
HasDBid
NodeType
=>
NodeId
->
DBCmd
err
[
Node
HyperdataModel
]
getListsModelWithParentId
n
=
runOpaQuery
$
selectNodesWith'
n
(
Just
NodeModel
)
getCorporaWithParentId
::
HasDBid
NodeType
=>
NodeId
->
DBCmd
err
[
Node
HyperdataCorpus
]
getCorporaWithParentId
n
=
runOpaQuery
$
selectNodesWith'
n
(
Just
NodeCorpus
)
...
...
@@ -309,12 +276,6 @@ selectNodesIdWithType nt = proc () -> do
restrict
-<
tn
.==
(
sqlInt4
$
toDBid
nt
)
returnA
-<
_node_id
row
------------------------------------------------------------------------
nodeExists
::
(
HasNodeError
err
)
=>
NodeId
->
DBCmd
err
Bool
nodeExists
nId
=
(
==
[
PGS
.
Only
True
])
<$>
runPGSQuery
[
sql
|
SELECT true FROM nodes WHERE id = ?
|]
(
PGS
.
Only
nId
)
getNode
::
HasNodeError
err
=>
NodeId
->
DBCmd
err
(
Node
Value
)
getNode
nId
=
do
maybeNode
<-
headMay
<$>
runOpaQuery
(
selectNode
(
pgNodeId
nId
))
...
...
@@ -380,33 +341,10 @@ node nodeType name hyperData parentId userId =
typeId
=
toDBid
nodeType
-------------------------------
insertNodes
::
[
NodeWrite
]
->
DBCmd
err
Int64
insertNodes
ns
=
mkCmd
$
\
conn
->
runInsert_
conn
$
Insert
nodeTable
ns
rCount
Nothing
{-
insertNodes' :: [Node a] -> DBCmd err Int64
insertNodes' ns = mkCmd $ \conn -> runInsert_ conn
$ Insert nodeTable ns' rCount Nothing
where
ns' :: [NodeWrite]
ns' = map (\(Node i t u p n d h)
-> Node (pgNodeId <$> i)
(sqlInt4 $ toDBid t)
(sqlInt4 u)
(pgNodeId <$> p)
(sqlStrictText n)
(pgUTCTime <$> d)
(pgJSONB $ cs $ encode h)
) ns
-}
insertNodesR
::
[
NodeWrite
]
->
DBCmd
err
[
NodeId
]
insertNodesR
ns
=
mkCmd
$
\
conn
->
runInsert_
conn
(
Insert
nodeTable
ns
(
rReturning
(
\
(
Node
i
_
_
_
_
_
_
_
)
->
i
))
Nothing
)
insertNodesWithParent
::
Maybe
ParentId
->
[
NodeWrite
]
->
DBCmd
err
Int64
insertNodesWithParent
pid
ns
=
insertNodes
(
set
node_parent_id
(
pgNodeId
<$>
pid
)
<$>
ns
)
insertNodesWithParentR
::
Maybe
ParentId
->
[
NodeWrite
]
->
DBCmd
err
[
NodeId
]
insertNodesWithParentR
pid
ns
=
insertNodesR
(
set
node_parent_id
(
pgNodeId
<$>
pid
)
<$>
ns
)
------------------------------------------------------------------------
...
...
@@ -414,33 +352,12 @@ insertNodesWithParentR pid ns = insertNodesR (set node_parent_id (pgNodeId <$> p
-- currently this function removes the child relation
-- needs a Temporary type between Node' and NodeWriteT
node2table
::
HasDBid
NodeType
=>
UserId
->
Maybe
ParentId
->
Node'
->
NodeWrite
node2table
uid
pid
(
Node'
nt
txt
v
[]
)
=
Node
Nothing
Nothing
(
sqlInt4
$
toDBid
nt
)
(
sqlInt4
$
_UserId
uid
)
(
fmap
pgNodeId
pid
)
(
sqlStrictText
txt
)
Nothing
(
sqlStrictJSONB
$
cs
$
encode
v
)
node2table
_
_
(
Node'
_
_
_
_
)
=
panicTrace
"node2table: should not happen, Tree insert not implemented yet"
data
Node'
=
Node'
{
_n_type
::
NodeType
,
_n_name
::
Text
,
_n_data
::
Value
,
_n_children
::
[
Node'
]
}
deriving
(
Show
)
mkNodes
::
[
NodeWrite
]
->
DBCmd
err
Int64
mkNodes
ns
=
mkCmd
$
\
conn
->
runInsert_
conn
$
Insert
nodeTable
ns
rCount
Nothing
mkNodeR
::
[
NodeWrite
]
->
DBCmd
err
[
NodeId
]
mkNodeR
ns
=
mkCmd
$
\
conn
->
runInsert_
conn
$
Insert
nodeTable
ns
(
rReturning
_node_id
)
Nothing
------------------------------------------------------------------------
childWith
::
HasDBid
NodeType
=>
UserId
->
ParentId
->
Node'
->
NodeWrite
childWith
uId
pId
(
Node'
NodeDocument
txt
v
[]
)
=
node2table
uId
(
Just
pId
)
(
Node'
NodeDocument
txt
v
[]
)
childWith
uId
pId
(
Node'
NodeContact
txt
v
[]
)
=
node2table
uId
(
Just
pId
)
(
Node'
NodeContact
txt
v
[]
)
childWith
_
_
(
Node'
_
_
_
_
)
=
panicTrace
"This NodeType can not be a child"
-- =================================================================== --
-- |
-- CorpusDocument is a corpus made from a set of documents
...
...
@@ -477,9 +394,6 @@ defaultList :: (HasNodeError err, HasDBid NodeType) => CorpusId -> DBCmd err Lis
defaultList
cId
=
maybe
(
nodeError
(
NoListFound
cId
))
(
pure
.
view
node_id
)
.
headMay
=<<
getListsWithParentId
cId
defaultListMaybe
::
(
HasNodeError
err
,
HasDBid
NodeType
)
=>
CorpusId
->
DBCmd
err
(
Maybe
NodeId
)
defaultListMaybe
cId
=
headMay
<$>
map
(
view
node_id
)
<$>
getListsWithParentId
cId
getListsWithParentId
::
HasDBid
NodeType
=>
NodeId
->
DBCmd
err
[
Node
HyperdataList
]
getListsWithParentId
n
=
runOpaQuery
$
selectNodesWith'
n
(
Just
NodeList
)
...
...
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