Some test code for ngrams coutn

parent cff88cad
use_nix use_nix
export LANG=C.UTF-8 export LANG=C.UTF-8
PATH_add $HOME/.ghcup/bin
...@@ -93,6 +93,7 @@ library ...@@ -93,6 +93,7 @@ library
Gargantext.Database.Admin.Types.Hyperdata Gargantext.Database.Admin.Types.Hyperdata
Gargantext.Database.Admin.Types.Node Gargantext.Database.Admin.Types.Node
Gargantext.Database.Prelude Gargantext.Database.Prelude
Gargantext.Database.Query.FacetTest
Gargantext.Database.Query.Table.NgramsPostag Gargantext.Database.Query.Table.NgramsPostag
Gargantext.Database.Query.Table.Node Gargantext.Database.Query.Table.Node
Gargantext.Database.Query.Table.Node.UpdateOpaleye Gargantext.Database.Query.Table.Node.UpdateOpaleye
......
...@@ -122,6 +122,7 @@ library: ...@@ -122,6 +122,7 @@ library:
- Gargantext.Database.Query.Table.Node - Gargantext.Database.Query.Table.Node
- Gargantext.Database.Query.Table.Node.UpdateOpaleye - Gargantext.Database.Query.Table.Node.UpdateOpaleye
- Gargantext.Database.Query.Table.User - Gargantext.Database.Query.Table.User
- Gargantext.Database.Query.FacetTest
- Gargantext.Database.Schema.Ngrams - Gargantext.Database.Schema.Ngrams
- Gargantext.Defaults - Gargantext.Defaults
- Gargantext.Utils.Jobs - Gargantext.Utils.Jobs
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
let let
myBuildInputs = [ myBuildInputs = [
pkgs.pkgs.docker-compose pkgs.pkgs.docker-compose
pkgs.pkgs.haskell-language-server #pkgs.pkgs.haskell-language-server
#pkgs.pkgs.haskellPackages.implicit-hie
pkgs.pkgs.stack pkgs.pkgs.stack
]; ];
in in
......
...@@ -20,6 +20,7 @@ module Gargantext.Database.Query.Facet ...@@ -20,6 +20,7 @@ module Gargantext.Database.Query.Facet
, runViewDocuments , runViewDocuments
, viewDocuments , viewDocuments
--, viewDocuments' --, viewDocuments'
, viewDocumentsAgg
, runCountDocuments , runCountDocuments
, filterWith , filterWith
, runTestAgg , runTestAgg
...@@ -176,6 +177,24 @@ viewDocuments cId t ntId mQuery mYear = proc () -> do ...@@ -176,6 +177,24 @@ viewDocuments cId t ntId mQuery mYear = proc () -> do
, facetDoc_score = toNullable $ nc^.nc_score , 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 viewDocuments' :: CorpusId
-> IsTrash -> IsTrash
-> NodeTypeId -> NodeTypeId
...@@ -183,10 +202,15 @@ viewDocuments' :: CorpusId ...@@ -183,10 +202,15 @@ viewDocuments' :: CorpusId
-> Maybe Text -> Maybe Text
-> Select FacetDocAgg -> Select FacetDocAgg
viewDocuments' cId t ntId mQuery mYear = proc () -> do 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 agg <- (laterally . OAgg.aggregate) sumInt4
(proc fd' -> do (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 } 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