2 Module : Gargantext.Database.Flow.Utils
3 Description : Database Flow
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
13 module Gargantext.Database.Action.Flow.Utils
17 import Data.HashMap.Strict (HashMap)
18 import Gargantext.Database.Admin.Types.Node
19 import Gargantext.Database.Prelude (Cmd)
20 import Gargantext.Database.Query.Table.ContextNodeNgrams
21 import Gargantext.Database.Schema.Ngrams
22 import Gargantext.Database.Types
23 import Gargantext.Prelude
24 import Control.Lens ((^.))
25 import qualified Data.Map as DM
26 import qualified Data.HashMap.Strict as HashMap
29 data DocumentIdWithNgrams a b =
31 { documentWithId :: Indexed NodeId a
32 , documentNgrams :: HashMap b (Map NgramsType Int)
35 insertDocNgrams :: ListId
36 -> HashMap (Indexed NgramsId Ngrams) (Map NgramsType (Map DocId Int))
38 insertDocNgrams lId m = insertContextNodeNgrams ns
40 ns = [ ContextNodeNgrams docId lId (ng^.index)
43 | (ng, t2n2i) <- HashMap.toList m
44 , (t, n2i) <- DM.toList t2n2i
45 , (docId, i) <- DM.toList n2i