import Gargantext.Core.Types
import Gargantext.Database.Admin.Config (nodeTypeId)
import Gargantext.Database.Admin.Types.Hyperdata (HyperdataDocument(..), HyperdataContact(..))
-import Gargantext.Database.Admin.Types.Node (NodeType(..))
import Gargantext.Database.Prelude (Cmd, runPGSQuery, runOpaQuery, runCountOpaQuery)
import Gargantext.Database.Query.Facet
import Gargantext.Database.Query.Filter
import Gargantext.Database.Query.Table.NodeNode
import Gargantext.Database.Schema.Node
import Gargantext.Prelude
-import Gargantext.Text.Terms.Mono.Stem.En (stemIt)
+import Gargantext.Core.Text.Terms.Mono.Stem.En (stemIt)
import Opaleye hiding (Query, Order)
import Data.Profunctor.Product (p4)
import qualified Opaleye as O hiding (Order)
else (nn^.nn_category) .>= (toNullable $ pgInt4 1)
restrict -< (n ^. ns_search) @@ (pgTSQuery (unpack q))
restrict -< (n ^. ns_typename ) .== (pgInt4 $ nodeTypeId NodeDocument)
- returnA -< FacetDoc (n^.ns_id )
- (n^.ns_date )
- (n^.ns_name )
- (n^.ns_hyperdata)
- (nn^.nn_category)
- (nn^.nn_score )
+ returnA -< FacetDoc (n^.ns_id )
+ (n^.ns_date )
+ (n^.ns_name )
+ (n^.ns_hyperdata )
+ (nn^.nn_category )
+ (nn^.nn_score )
+ (nn^.nn_score )
joinInCorpus :: O.Query (NodeSearchRead, NodeNodeReadNull)
joinInCorpus = leftJoin queryNodeSearchTable queryNodeNodeTable cond
runOpaQuery $ limit' l
$ offset' o
$ orderBy ( desc _fp_score)
- $ group cId aId
+ $ selectGroup cId aId
$ intercalate " | "
$ map stemIt q
--- TODO group by
selectContactViaDoc
- :: CorpusId
- -> AnnuaireId
- -> Text
- -> Select FacetPairedReadNull
-selectContactViaDoc cId aId q = proc () -> do
- (doc, (corpus_doc, (_contact_doc, (annuaire_contact, contact)))) <- queryContactViaDoc -< ()
- restrict -< (doc^.ns_search) @@ (pgTSQuery $ unpack q )
- restrict -< (doc^.ns_typename) .== (pgInt4 $ nodeTypeId NodeDocument)
- restrict -< (corpus_doc^.nn_node1_id) .== (toNullable $ pgNodeId cId)
- restrict -< (annuaire_contact^.nn_node1_id) .== (toNullable $ pgNodeId aId)
- restrict -< (contact^.node_typename) .== (toNullable $ pgInt4 $ nodeTypeId NodeContact)
- returnA -< FacetPaired (contact^.node_id)
- (contact^.node_date)
- (contact^.node_hyperdata)
- (toNullable $ pgInt4 1)
-
-
-selectContactViaDoc'
:: CorpusId
-> AnnuaireId
-> Text
, Column (Nullable PGJsonb)
, Column (Nullable PGInt4)
)
-selectContactViaDoc' cId aId q = proc () -> do
+selectContactViaDoc cId aId q = proc () -> do
(doc, (corpus_doc, (_contact_doc, (annuaire_contact, contact)))) <- queryContactViaDoc -< ()
restrict -< (doc^.ns_search) @@ (pgTSQuery $ unpack q )
restrict -< (doc^.ns_typename) .== (pgInt4 $ nodeTypeId NodeDocument)
, toNullable $ pgInt4 1
)
-group :: NodeId
+selectGroup :: NodeId
-> NodeId
-> Text
-> Select FacetPairedReadNull
-group cId aId q = proc () -> do
+selectGroup cId aId q = proc () -> do
(a, b, c, d) <- aggregate (p4 (groupBy, groupBy, groupBy, O.sum))
- (selectContactViaDoc' cId aId q) -< ()
+ (selectContactViaDoc cId aId q) -< ()
returnA -< FacetPaired a b c d
-
-
-
-
-
-
queryContactViaDoc :: O.Query ( NodeSearchRead
, ( NodeNodeReadNull
, ( NodeNodeReadNull