Commit b48eef4d authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] Graph Search with selected node (context migration related)

parent 8d7076d5
...@@ -25,8 +25,11 @@ import Gargantext.Database.Query.Facet ...@@ -25,8 +25,11 @@ import Gargantext.Database.Query.Facet
import Gargantext.Database.Query.Filter import Gargantext.Database.Query.Filter
import Gargantext.Database.Query.Join (leftJoin5) import Gargantext.Database.Query.Join (leftJoin5)
import Gargantext.Database.Query.Table.Node import Gargantext.Database.Query.Table.Node
import Gargantext.Database.Query.Table.Context
import Gargantext.Database.Query.Table.NodeNode import Gargantext.Database.Query.Table.NodeNode
import Gargantext.Database.Query.Table.NodeContext
import Gargantext.Database.Schema.Node import Gargantext.Database.Schema.Node
import Gargantext.Database.Schema.Context
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Core.Text.Terms.Mono.Stem.En (stemIt) import Gargantext.Core.Text.Terms.Mono.Stem.En (stemIt)
import Opaleye hiding (Order) import Opaleye hiding (Order)
...@@ -80,27 +83,27 @@ queryInCorpus :: HasDBid NodeType ...@@ -80,27 +83,27 @@ queryInCorpus :: HasDBid NodeType
-> Text -> Text
-> O.Select FacetDocRead -> O.Select FacetDocRead
queryInCorpus cId t q = proc () -> do queryInCorpus cId t q = proc () -> do
(n, nn) <- joinInCorpus -< () (c, nc) <- joinInCorpus -< ()
restrict -< (nn^.nn_node1_id) .== (toNullable $ pgNodeId cId) restrict -< (nc^.nc_node_id) .== (toNullable $ pgNodeId cId)
restrict -< if t restrict -< if t
then (nn^.nn_category) .== (toNullable $ sqlInt4 0) then (nc^.nc_category) .== (toNullable $ sqlInt4 0)
else (nn^.nn_category) .>= (toNullable $ sqlInt4 1) else (nc^.nc_category) .>= (toNullable $ sqlInt4 1)
restrict -< (n ^. ns_search) @@ (sqlTSQuery (unpack q)) restrict -< (c ^. cs_search) @@ (sqlTSQuery (unpack q))
restrict -< (n ^. ns_typename ) .== (sqlInt4 $ toDBid NodeDocument) restrict -< (c ^. cs_typename ) .== (sqlInt4 $ toDBid NodeDocument)
returnA -< FacetDoc { facetDoc_id = n^.ns_id returnA -< FacetDoc { facetDoc_id = c^.cs_id
, facetDoc_created = n^.ns_date , facetDoc_created = c^.cs_date
, facetDoc_title = n^.ns_name , facetDoc_title = c^.cs_name
, facetDoc_hyperdata = n^.ns_hyperdata , facetDoc_hyperdata = c^.cs_hyperdata
, facetDoc_category = nn^.nn_category , facetDoc_category = nc^.nc_category
, facetDoc_ngramCount = nn^.nn_score , facetDoc_ngramCount = nc^.nc_score
, facetDoc_score = nn^.nn_score , facetDoc_score = nc^.nc_score
} }
joinInCorpus :: O.Select (NodeSearchRead, NodeNodeReadNull) joinInCorpus :: O.Select (ContextSearchRead, NodeContextReadNull)
joinInCorpus = leftJoin queryNodeSearchTable queryNodeNodeTable cond joinInCorpus = leftJoin queryContextSearchTable queryNodeContextTable cond
where where
cond :: (NodeSearchRead, NodeNodeRead) -> Column SqlBool cond :: (ContextSearchRead, NodeContextRead) -> Column SqlBool
cond (n, nn) = nn^.nn_node2_id .== _ns_id n cond (c, nc) = nc^.nc_context_id .== _cs_id c
------------------------------------------------------------------------ ------------------------------------------------------------------------
searchInCorpusWithContacts searchInCorpusWithContacts
......
...@@ -20,7 +20,7 @@ Portability : POSIX ...@@ -20,7 +20,7 @@ Portability : POSIX
module Gargantext.Database.Query.Facet module Gargantext.Database.Query.Facet
( runViewAuthorsDoc ( runViewAuthorsDoc
, runViewDocuments , runViewDocuments
, viewDocuments' -- , viewDocuments'
, runCountDocuments , runCountDocuments
, filterWith , filterWith
...@@ -306,8 +306,7 @@ runViewDocuments cId t o l order query = do ...@@ -306,8 +306,7 @@ runViewDocuments cId t o l order query = do
printDebug "[runViewDocuments] sqlQuery" $ showSql sqlQuery printDebug "[runViewDocuments] sqlQuery" $ showSql sqlQuery
runOpaQuery $ filterWith o l order sqlQuery runOpaQuery $ filterWith o l order sqlQuery
where where
ntId = toDBid NodeDocument sqlQuery = viewDocuments cId t (toDBid NodeDocument) query
sqlQuery = viewDocuments cId t ntId query
runCountDocuments :: HasDBid NodeType => CorpusId -> IsTrash -> Maybe Text -> Cmd err Int runCountDocuments :: HasDBid NodeType => CorpusId -> IsTrash -> Maybe Text -> Cmd err Int
runCountDocuments cId t mQuery = do runCountDocuments cId t mQuery = do
...@@ -331,22 +330,6 @@ viewDocuments cId t ntId mQuery = viewDocumentsQuery cId t ntId mQuery >>> proc ...@@ -331,22 +330,6 @@ viewDocuments cId t ntId mQuery = viewDocumentsQuery cId t ntId mQuery >>> proc
, facetDoc_score = toNullable $ nc^.nc_score , facetDoc_score = toNullable $ nc^.nc_score
} }
viewDocuments' :: CorpusId
-> IsTrash
-> NodeTypeId
-> Maybe Text
-> Select NodeRead
viewDocuments' cId t ntId mQuery = viewDocumentsQuery cId t ntId mQuery >>> proc (c, _nc) -> do
returnA -< Node { _node_id = _cs_id c
, _node_hash_id = ""
, _node_typename = _cs_typename c
, _node_user_id = _cs_user_id c
, _node_parent_id = -1
, _node_name = _cs_name c
, _node_date = _cs_date c
, _node_hyperdata = _cs_hyperdata c
}
viewDocumentsQuery :: CorpusId viewDocumentsQuery :: CorpusId
-> IsTrash -> IsTrash
-> NodeTypeId -> NodeTypeId
......
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