Commit e16a4fc5 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[searx] fix language sent by user

parent 867e66e5
...@@ -120,7 +120,7 @@ insertSearxResponse :: (MonadBase IO m, FlowCmdM env err m) ...@@ -120,7 +120,7 @@ insertSearxResponse :: (MonadBase IO m, FlowCmdM env err m)
-> m () -> m ()
insertSearxResponse _ _ _ _ (Left _) = pure () insertSearxResponse _ _ _ _ (Left _) = pure ()
insertSearxResponse user cId listId l (Right (SearxResponse { _srs_results })) = do insertSearxResponse user cId listId l (Right (SearxResponse { _srs_results })) = do
let docs = hyperdataDocumentFromSearxResult <$> _srs_results let docs = hyperdataDocumentFromSearxResult l <$> _srs_results
--printDebug "[triggerSearxSearch] docs" docs --printDebug "[triggerSearxSearch] docs" docs
-- docs :: [Either Text HyperdataDocument] -- docs :: [Either Text HyperdataDocument]
let docs' = catMaybes $ rightToMaybe <$> docs let docs' = catMaybes $ rightToMaybe <$> docs
...@@ -130,9 +130,9 @@ insertSearxResponse user cId listId l (Right (SearxResponse { _srs_results })) = ...@@ -130,9 +130,9 @@ insertSearxResponse user cId listId l (Right (SearxResponse { _srs_results })) =
" :: [publication_year] " <> (show _hd_publication_year) <> " :: [publication_year] " <> (show _hd_publication_year) <>
" :: [publication_date] " <> (show _hd_publication_date) " :: [publication_date] " <> (show _hd_publication_date)
) docs' ) docs'
--_ <- flowDataText user (DataNew [docs']) (Multi EN) cId Nothing logStatus --_ <- flowDataText user (DataNew [docs']) (Multi l) cId Nothing logStatus
let mCorpus = Nothing :: Maybe HyperdataCorpus let mCorpus = Nothing :: Maybe HyperdataCorpus
ids <- insertMasterDocs mCorpus (Multi EN) docs' ids <- insertMasterDocs mCorpus (Multi l) docs'
_ <- Doc.add cId ids _ <- Doc.add cId ids
(_masterUserId, _masterRootId, masterCorpusId) (_masterUserId, _masterRootId, masterCorpusId)
<- getOrMk_RootWithCorpus (UserName userMaster) (Left "") mCorpus <- getOrMk_RootWithCorpus (UserName userMaster) (Left "") mCorpus
...@@ -169,9 +169,6 @@ triggerSearxSearch user cId q l logStatus = do ...@@ -169,9 +169,6 @@ triggerSearxSearch user cId q l logStatus = do
mListId <- defaultListMaybe cId mListId <- defaultListMaybe cId
listId <- case mListId of listId <- case mListId of
Nothing -> do Nothing -> do
--let failedJobLog = jobLogFailTotalWithMessage "[triggerSearxSearch] no list id" jobLog
--logStatus failedJobLog
--pure failedJobLog
listId <- getOrMkList cId uId listId <- getOrMkList cId uId
pure listId pure listId
Just listId -> pure listId Just listId -> pure listId
...@@ -197,8 +194,8 @@ triggerSearxSearch user cId q l logStatus = do ...@@ -197,8 +194,8 @@ triggerSearxSearch user cId q l logStatus = do
pure $ jobLogSuccess jobLog pure $ jobLogSuccess jobLog
hyperdataDocumentFromSearxResult :: SearxResult -> Either T.Text HyperdataDocument hyperdataDocumentFromSearxResult :: Lang -> SearxResult -> Either T.Text HyperdataDocument
hyperdataDocumentFromSearxResult (SearxResult { _sr_content, _sr_engine, _sr_pubdate, _sr_title }) = do hyperdataDocumentFromSearxResult l (SearxResult { _sr_content, _sr_engine, _sr_pubdate, _sr_title }) = do
let mDate = parseTimeM False defaultTimeLocale "%Y-%m-%d %H:%M:%S+0000" (T.unpack _sr_pubdate) :: Maybe Day let mDate = parseTimeM False defaultTimeLocale "%Y-%m-%d %H:%M:%S+0000" (T.unpack _sr_pubdate) :: Maybe Day
let mGregorian = toGregorian <$> mDate let mGregorian = toGregorian <$> mDate
Right HyperdataDocument { _hd_bdd = Just "Searx" Right HyperdataDocument { _hd_bdd = Just "Searx"
...@@ -219,5 +216,5 @@ hyperdataDocumentFromSearxResult (SearxResult { _sr_content, _sr_engine, _sr_pub ...@@ -219,5 +216,5 @@ hyperdataDocumentFromSearxResult (SearxResult { _sr_content, _sr_engine, _sr_pub
, _hd_publication_hour = Nothing , _hd_publication_hour = Nothing
, _hd_publication_minute = Nothing , _hd_publication_minute = Nothing
, _hd_publication_second = Nothing , _hd_publication_second = Nothing
, _hd_language_iso2 = Just $ T.pack $ show EN } , _hd_language_iso2 = Just $ T.pack $ show l }
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