[hyperdata] fix updating of corpus language

The bug was introduced in

!177 (diffs)

It caused hyperdata to be updated with whole corpus, serialized, hence
hyperdata inside hyperdata.
parent 04e82dd6
Pipeline #4412 passed with stage
in 25 seconds
...@@ -3,18 +3,18 @@ module Gargantext.API.Node.Corpus.Update ...@@ -3,18 +3,18 @@ module Gargantext.API.Node.Corpus.Update
( addLanguageToCorpus ) ( addLanguageToCorpus )
where where
import Control.Lens
import Control.Monad
import Data.Proxy
import Gargantext.Core import Gargantext.Core
import Gargantext.Database.Action.Flow.Types import Gargantext.Database.Action.Flow.Types
import Gargantext.Database.Admin.Types.Node
import Gargantext.Prelude
import Gargantext.Utils.Jobs
import Gargantext.Database.Admin.Types.Hyperdata.Corpus import Gargantext.Database.Admin.Types.Hyperdata.Corpus
import Gargantext.Database.Admin.Types.Node
import Gargantext.Database.Query.Table.Node import Gargantext.Database.Query.Table.Node
import Data.Proxy
import Control.Lens
import Gargantext.Database.Schema.Node (node_hyperdata)
import Gargantext.Database.Query.Table.Node.UpdateOpaleye (updateHyperdata) import Gargantext.Database.Query.Table.Node.UpdateOpaleye (updateHyperdata)
import Control.Monad import Gargantext.Database.Schema.Node (node_hyperdata)
import Gargantext.Prelude
import Gargantext.Utils.Jobs
-- | Updates the 'HyperdataCorpus' with the input 'Lang'. -- | Updates the 'HyperdataCorpus' with the input 'Lang'.
addLanguageToCorpus :: (FlowCmdM env err m, MonadJobStatus m) addLanguageToCorpus :: (FlowCmdM env err m, MonadJobStatus m)
...@@ -24,4 +24,4 @@ addLanguageToCorpus :: (FlowCmdM env err m, MonadJobStatus m) ...@@ -24,4 +24,4 @@ addLanguageToCorpus :: (FlowCmdM env err m, MonadJobStatus m)
addLanguageToCorpus cId lang = do addLanguageToCorpus cId lang = do
hyperNode <- getNodeWith cId (Proxy @HyperdataCorpus) hyperNode <- getNodeWith cId (Proxy @HyperdataCorpus)
let hyperNode' = hyperNode & over node_hyperdata (\corpus -> corpus { _hc_lang = Just lang }) let hyperNode' = hyperNode & over node_hyperdata (\corpus -> corpus { _hc_lang = Just lang })
void $ updateHyperdata cId hyperNode' void $ updateHyperdata cId $ hyperNode' ^. node_hyperdata
...@@ -35,7 +35,7 @@ data HyperdataCorpus = ...@@ -35,7 +35,7 @@ data HyperdataCorpus =
-- 'defaultLanguage' if we don't know which language it is. -- 'defaultLanguage' if we don't know which language it is.
, _hc_lang :: Maybe Lang , _hc_lang :: Maybe Lang
} }
deriving (Generic) deriving (Generic, Show)
defaultHyperdataCorpus :: HyperdataCorpus defaultHyperdataCorpus :: HyperdataCorpus
defaultHyperdataCorpus = defaultHyperdataCorpus =
......
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