Commit b3a00112 authored by Alfredo Di Napoli's avatar Alfredo Di Napoli

insertNodeNode is now private

This commit makes this function private to the `Table.NodeNode` module
as it's fairly low-level, and it doesn't let us embed logic to ensure we
are creating a valid node2node relationship. Better use one of the other
specialised functions.
parent 76b51c0c
......@@ -155,10 +155,7 @@ pairs cId = Named.Pairs $ do
pairWith :: IsGargServer err env m => CorpusId -> Named.PairWith (AsServerT m)
pairWith cId = Named.PairWith $ \ aId lId -> do
r <- pairing cId aId lId
_ <- insertNodeNode [ NodeNode { _nn_node1_id = cId
, _nn_node2_id = aId
, _nn_score = Nothing
, _nn_category = Nothing }]
pairCorpusWithAnnuaire (SourceId cId) (TargetId aId)
pure r
......
......@@ -71,7 +71,7 @@ pairing a c l' = do
Nothing -> defaultList c
Just l'' -> pure l''
dataPaired <- dataPairing a (c,l,Authors)
_ <- insertNodeNode [ NodeNode c a Nothing Nothing]
pairCorpusWithAnnuaire (SourceId c) (TargetId a)
insertNodeContext_NodeContext $ prepareInsert c a dataPaired
......
......@@ -34,13 +34,13 @@ module Gargantext.Database.Query.Table.NodeNode
-- * Destructive operations
, deleteNodeNode
, insertNodeNode
, nodeNodesCategory
, nodeNodesScore
, pairCorpusWithAnnuaire
, publishNode
, unpublishNode
, queryNodeNodeTable
, shareNode
, unpublishNode
)
where
......@@ -108,6 +108,11 @@ getNodeNodeWith pId _ maybeNodeType = runOpaQuery query
-}
------------------------------------------------------------------------
-- | Inserts a list of 'NodeNode', creating relationship between nodes
-- in the database. This function is deliberately not exposed, because
-- it's low-level and it doesn't do any business-logic check to ensure
-- the share being created is valid. Use the other functions like
-- 'shareNode', 'publishNode', or roll your own.
insertNodeNode :: [NodeNode] -> DBCmd err Int
insertNodeNode ns = mkCmd $ \conn -> fromIntegral <$> (runInsert_ conn
$ Insert nodeNodeTable ns' rCount (Just DoNothing))
......@@ -324,3 +329,9 @@ publishNode (SourceId sourceId) (TargetId targetId) =
unpublishNode :: SourceId -> TargetId -> DBCmd err ()
unpublishNode (SourceId sourceId) (TargetId targetId) =
void $ deleteNodeNode sourceId targetId
-- | Pair two nodes together. Typically used to pair
-- together
pairCorpusWithAnnuaire :: SourceId -> TargetId -> DBCmd err ()
pairCorpusWithAnnuaire (SourceId sourceId) (TargetId targetId) =
void $ insertNodeNode [ NodeNode sourceId targetId Nothing Nothing ]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment