Commit 1b2ffbc3 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[list selection] some initial work (doesn't compile)

parent 2a4febfe
Pipeline #1776 failed with stage
in 6 minutes and 23 seconds
...@@ -45,6 +45,7 @@ import Gargantext.API.Node.Corpus.Searx ...@@ -45,6 +45,7 @@ import Gargantext.API.Node.Corpus.Searx
import Gargantext.API.Node.Corpus.Types import Gargantext.API.Node.Corpus.Types
import Gargantext.API.Node.Types import Gargantext.API.Node.Types
import Gargantext.Core (Lang(..){-, allLangs-}) import Gargantext.Core (Lang(..){-, allLangs-})
import Gargantext.Core.Text.List.Social (FlowSocialListWith(..))
import qualified Gargantext.Core.Text.Corpus.API as API import qualified Gargantext.Core.Text.Corpus.API as API
import qualified Gargantext.Core.Text.Corpus.Parsers as Parser (FileFormat(..), parseFormat) import qualified Gargantext.Core.Text.Corpus.Parsers as Parser (FileFormat(..), parseFormat)
import Gargantext.Core.Types.Individu (User(..)) import Gargantext.Core.Types.Individu (User(..))
...@@ -132,12 +133,12 @@ info _u = pure $ ApiInfo API.externalAPIs ...@@ -132,12 +133,12 @@ info _u = pure $ ApiInfo API.externalAPIs
------------------------------------------------------------------------ ------------------------------------------------------------------------
------------------------------------------------------------------------ ------------------------------------------------------------------------
data WithQuery = WithQuery data WithQuery = WithQuery
{ _wq_query :: !Text { _wq_query :: !Text
, _wq_databases :: !Database , _wq_databases :: !Database
, _wq_datafield :: !Datafield , _wq_datafield :: !(Maybe Datafield)
, _wq_lang :: !Lang , _wq_lang :: !Lang
, _wq_node_id :: !Int , _wq_node_id :: !Int
-- , _wq_flowListWith :: !FlowSocialListWith , _wq_flowListWith :: !FlowSocialListWith
} }
deriving Generic deriving Generic
...@@ -190,7 +191,7 @@ addToCorpusWithQuery user cid (WithQuery q dbs datafield l _nid) maybeLimit logS ...@@ -190,7 +191,7 @@ addToCorpusWithQuery user cid (WithQuery q dbs datafield l _nid) maybeLimit logS
printDebug "[addToCorpusWithQuery] datafield" datafield printDebug "[addToCorpusWithQuery] datafield" datafield
case datafield of case datafield of
Web -> do Just Web -> do
printDebug "[addToCorpusWithQuery] processing web request" datafield printDebug "[addToCorpusWithQuery] processing web request" datafield
_ <- triggerSearxSearch cid q l _ <- triggerSearxSearch cid q l
......
...@@ -11,6 +11,8 @@ Portability : POSIX ...@@ -11,6 +11,8 @@ Portability : POSIX
module Gargantext.Core.Text.List.Social module Gargantext.Core.Text.List.Social
where where
import Control.Monad (mzero)
import Data.Aeson
import Data.HashMap.Strict (HashMap) import Data.HashMap.Strict (HashMap)
import Data.Map (Map) import Data.Map (Map)
import Data.Monoid (mconcat) import Data.Monoid (mconcat)
...@@ -39,7 +41,16 @@ import Gargantext.Prelude ...@@ -39,7 +41,16 @@ import Gargantext.Prelude
data FlowSocialListWith = FlowSocialListWithPriority { fslw_priority :: FlowSocialListPriority } data FlowSocialListWith = FlowSocialListWithPriority { fslw_priority :: FlowSocialListPriority }
| FlowSocialListWithLists { fslw_lists :: [ListId] } | FlowSocialListWithLists { fslw_lists :: [ListId] }
instance FromJSON FlowSocialListWith where
parseJSON (Object v) = do
typ <- v .: "type"
value <- v .:? "value" .!= []
case typ of
"MyListsFirst" -> pure $ FlowSocialListWithPriority { fslw_priority = MySelfFirst }
"OtherListsFirst" -> pure $ FlowSocialListWithPriority { fslw_priority = OthersFirst }
"SelectedLists" -> pure $ FlowSocialListWithLists { fslw_lists = v }
_ -> pure $ FlowSocialListWithPriority { fslw_priority = MySelfFirst }
parseJSON _ = mzero
data FlowSocialListPriority = MySelfFirst | OthersFirst data FlowSocialListPriority = MySelfFirst | OthersFirst
flowSocialListPriority :: FlowSocialListPriority -> [NodeMode] flowSocialListPriority :: FlowSocialListPriority -> [NodeMode]
......
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