Commit 2abc5056 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[NGRAMS][TABLE] grouping parent/children.

parent 23378ee6
Pipeline #12 canceled with stage
......@@ -240,13 +240,14 @@ type ListIdUser = Int
type ListIdMaster = Int
type MapChildren = Map Text (Set Text)
type MapParent = Map Text Text
getNgramsGroup :: DPS.Connection -> ListIdUser -> ListIdMaster -> IO (Map Text (Set Text))
getNgramsGroup conn lu lm = fromListWith (<>)
<$> map (\(a,b) -> (a, DS.singleton b))
<$> getNgramsGroup' conn lu lm
type MapParent = Map Text (Set Text)
getNgramsGroup :: DPS.Connection -> ListIdUser -> ListIdMaster -> IO (MapParent, MapChildren)
getNgramsGroup conn lu lm = do
groups <- getNgramsGroup' conn lu lm
let mapChildren = fromListWith (<>) $ map (\(a,b) -> (a, DS.singleton b)) groups
let mapParent = fromListWith (<>) $ map (\(a,b) -> (b, DS.singleton a)) groups
pure (mapParent, mapChildren)
getNgramsGroup' :: DPS.Connection -> ListIdUser -> ListIdMaster -> IO [(Text,Text)]
getNgramsGroup' conn lu lm = DPS.query conn querySelectNgramsGroup (lu,lm)
......
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