2 Module : Gargantext.Core.Text.List.Social
4 Copyright : (c) CNRS, 2018-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
11 module Gargantext.Core.Text.List.Social
14 import Data.Monoid (mconcat)
15 import Data.Text (Text)
16 import Gargantext.API.Ngrams.Tools
17 import Gargantext.API.Ngrams.Types
18 import Gargantext.Core.Text.List.Social.Find
19 import Gargantext.Core.Text.List.Social.Prelude
20 import Gargantext.Core.Text.List.Social.Scores
21 import Gargantext.Core.Types.Individu
22 import Gargantext.Database.Admin.Types.Node
23 import Gargantext.Database.Prelude
24 import Gargantext.Database.Query.Table.Node.Error
25 import Gargantext.Database.Query.Tree
26 import Gargantext.Database.Schema.Ngrams
27 import Gargantext.Prelude
29 ------------------------------------------------------------------------
30 ------------------------------------------------------------------------
33 -- | FlowSocialListPriority
34 -- Sociological assumption: either private or others (public) first
35 -- This parameter depends on the user choice
36 data FlowSocialListPriority = MySelfFirst | OthersFirst
38 flowSocialListPriority :: FlowSocialListPriority -> [NodeMode]
39 flowSocialListPriority MySelfFirst = [Private, Shared{-, Public -}]
40 flowSocialListPriority OthersFirst = reverse $ flowSocialListPriority MySelfFirst
43 -- | We keep the parents for all ngrams but terms
44 keepAllParents :: NgramsType -> KeepAllParents
45 keepAllParents NgramsTerms = KeepAllParents False
46 keepAllParents _ = KeepAllParents True
48 ------------------------------------------------------------------------
49 flowSocialList' :: ( RepoCmdM env err m
54 => FlowSocialListPriority
56 -> FlowCont Text FlowListScores
57 -> m (FlowCont Text FlowListScores)
58 flowSocialList' flowPriority user nt flc =
59 mconcat <$> mapM (flowSocialListByMode' user nt flc)
60 (flowSocialListPriority flowPriority)
63 flowSocialListByMode' :: ( RepoCmdM env err m
69 -> FlowCont Text FlowListScores
71 -> m (FlowCont Text FlowListScores)
72 flowSocialListByMode' user' nt' flc' mode =
73 findListsId user' mode
74 >>= flowSocialListByModeWith nt' flc'
77 flowSocialListByModeWith :: ( RepoCmdM env err m
83 -> FlowCont Text FlowListScores
85 -> m (FlowCont Text FlowListScores)
86 flowSocialListByModeWith nt'' flc'' ns =
87 mapM (\l -> getListNgrams [l] nt'') ns
89 . toFlowListScores (keepAllParents nt'') flc''