Some test code for ngrams coutn

parent cff88cad
use_nix
export LANG=C.UTF-8
PATH_add $HOME/.ghcup/bin
......@@ -93,6 +93,7 @@ library
Gargantext.Database.Admin.Types.Hyperdata
Gargantext.Database.Admin.Types.Node
Gargantext.Database.Prelude
Gargantext.Database.Query.FacetTest
Gargantext.Database.Query.Table.NgramsPostag
Gargantext.Database.Query.Table.Node
Gargantext.Database.Query.Table.Node.UpdateOpaleye
......
......@@ -122,6 +122,7 @@ library:
- Gargantext.Database.Query.Table.Node
- Gargantext.Database.Query.Table.Node.UpdateOpaleye
- Gargantext.Database.Query.Table.User
- Gargantext.Database.Query.FacetTest
- Gargantext.Database.Schema.Ngrams
- Gargantext.Defaults
- Gargantext.Utils.Jobs
......
......@@ -2,7 +2,8 @@
let
myBuildInputs = [
pkgs.pkgs.docker-compose
pkgs.pkgs.haskell-language-server
#pkgs.pkgs.haskell-language-server
#pkgs.pkgs.haskellPackages.implicit-hie
pkgs.pkgs.stack
];
in
......
......@@ -20,6 +20,7 @@ module Gargantext.Database.Query.Facet
, runViewDocuments
, viewDocuments
--, viewDocuments'
, viewDocumentsAgg
, runCountDocuments
, filterWith
, runTestAgg
......@@ -176,6 +177,24 @@ viewDocuments cId t ntId mQuery mYear = proc () -> do
, facetDoc_score = toNullable $ nc^.nc_score
}
viewDocumentsNonNull :: CorpusId
-> IsTrash
-> NodeTypeId
-> Maybe Text
-> Maybe Text
-> Select FacetDocAggPart
viewDocumentsNonNull cId t ntId mQuery mYear = proc () -> do
(c, nc) <- viewDocumentsQuery cId t ntId mQuery mYear -< ()
returnA -< FacetDoc { facetDoc_id = _cs_id c
, facetDoc_created = _cs_date c
, facetDoc_title = _cs_name c
, facetDoc_hyperdata = _cs_hyperdata c
, facetDoc_category = nc^.nc_category
, facetDoc_ngramCount = 0 -- nc^.nc_score
, facetDoc_score = nc^.nc_score
}
viewDocuments' :: CorpusId
-> IsTrash
-> NodeTypeId
......@@ -183,10 +202,15 @@ viewDocuments' :: CorpusId
-> Maybe Text
-> Select FacetDocAgg
viewDocuments' cId t ntId mQuery mYear = proc () -> do
fd <- viewDocumentsAgg cId t ntId mQuery mYear -< ()
-- fd <- viewDocumentsAgg cId t ntId mQuery mYear -< ()
fd <- viewDocumentsNonNull cId t ntId mQuery mYear -< ()
agg <- (laterally . OAgg.aggregate) sumInt4
(proc fd' -> do
returnA -< facetDoc_ngramCount fd') -< fd
cnng <- optionalRestrict queryContextNodeNgramsTable -<
\cnng' -> (cnng' ^. cnng_node_id) .== pgNodeId cId .&&
(cnng' ^. cnng_context_id) .== facetDoc_id fd'
returnA -< matchMaybe cnng $ maybe 0 _cnng_doc_count) -< fd
returnA -< fd { facetDoc_ngramCount = agg }
......
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