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

[NGRAMS][TABLE] grouping parent/children.

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