Commit e6bd5c6f authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] NodeWrites parsing first fix

parent aeb9e7bd
Pipeline #3609 failed with stage
in 53 minutes and 25 seconds
...@@ -20,8 +20,9 @@ import Conduit ...@@ -20,8 +20,9 @@ import Conduit
import Control.Lens ((^.)) import Control.Lens ((^.))
import Data.Aeson import Data.Aeson
import Data.Either (Either(..), rights) import Data.Either (Either(..), rights)
-- import Data.Maybe (fromMaybe)
import Data.Swagger import Data.Swagger
import qualified Data.Text as T import GHC.Generics (Generic)
import Gargantext.API.Admin.EnvTypes (Env, GargJob(..)) import Gargantext.API.Admin.EnvTypes (Env, GargJob(..))
import Gargantext.API.Admin.Orchestrator.Types (JobLog(..), AsyncJobs) import Gargantext.API.Admin.Orchestrator.Types (JobLog(..), AsyncJobs)
import Gargantext.API.Admin.Types (HasSettings) import Gargantext.API.Admin.Types (HasSettings)
...@@ -38,12 +39,12 @@ import Gargantext.Database.Admin.Types.Hyperdata.Frame ...@@ -38,12 +39,12 @@ import Gargantext.Database.Admin.Types.Hyperdata.Frame
import Gargantext.Database.Admin.Types.Node import Gargantext.Database.Admin.Types.Node
import Gargantext.Database.Query.Table.Node (getChildrenByType, getClosestParentIdByType', getNodeWith) import Gargantext.Database.Query.Table.Node (getChildrenByType, getClosestParentIdByType', getNodeWith)
import Gargantext.Database.Schema.Node (node_hyperdata) import Gargantext.Database.Schema.Node (node_hyperdata)
import qualified Data.List as List
import qualified Gargantext.Defaults as Defaults
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Utils.Jobs (serveJobsAPI) import Gargantext.Utils.Jobs (serveJobsAPI)
import GHC.Generics (Generic)
import Servant import Servant
import qualified Data.List as List
import qualified Data.Text as T
import qualified Gargantext.Defaults as Defaults
------------------------------------------------------------------------ ------------------------------------------------------------------------
type API = Summary " Documents from Write nodes." type API = Summary " Documents from Write nodes."
...@@ -99,13 +100,36 @@ documentsFromWriteNodes uId nId _p logStatus = do ...@@ -99,13 +100,36 @@ documentsFromWriteNodes uId nId _p logStatus = do
) frameWrites ) frameWrites
let parsedE = (\(node, contents) -> hyperdataDocumentFromFrameWrite 7 (node ^. node_hyperdata, contents)) <$> frameWritesWithContents let parsedE = (\(node, contents) -> hyperdataDocumentFromFrameWrite 7 (node ^. node_hyperdata, contents)) <$> frameWritesWithContents
-- TODO hard coded param should be take -- TODO hard coded param should be taken from user
let parsed = List.concat $ rights parsedE let parsed = List.concat $ rights parsedE
_ <- flowDataText (RootId (NodeId uId)) (DataNew (Just $ fromIntegral $ length parsed, yieldMany parsed)) (Multi EN) cId Nothing logStatus _ <- flowDataText (RootId (NodeId uId))
(DataNew (Just $ fromIntegral $ length parsed, yieldMany parsed))
(Multi EN) cId Nothing logStatus
pure $ jobLogSuccess jobLog pure $ jobLogSuccess jobLog
------------------------------------------------------------------------ ------------------------------------------------------------------------
{-
-- extractFrameWrites :: (HasSettings env, FlowCmdM env err m) => NodeId -> m [Node T.Text]
extractFrameWrites nId = do
mcId <- getClosestParentIdByType' nId NodeCorpus
frameWriteIds <- getChildrenByType (fromMaybe (panic "[G.A.N.DocumentsFromWriteNodes] No parent found") mcId) NodeFrameWrite
-- https://write.frame.gargantext.org/<frame_id>/download
frameWrites <- mapM (\id -> getNodeWith id (Proxy :: Proxy HyperdataFrame)) frameWriteIds
frameWritesWithContents <- liftBase $
mapM (\node -> do
contents <- getHyperdataFrameContents (node ^. node_hyperdata)
pure (node, contents)
) frameWrites
let parsedE = (\(node, contents) -> hyperdataDocumentFromFrameWrite 7 (node ^. node_hyperdata, contents)) <$> frameWritesWithContents
let parsed = List.concat $ rights parsedE
pure parsed
-}
------------------------------------------------------------------------
hyperdataDocumentFromFrameWrite :: Int -> (HyperdataFrame, T.Text) -> Either T.Text [HyperdataDocument] hyperdataDocumentFromFrameWrite :: Int -> (HyperdataFrame, T.Text) -> Either T.Text [HyperdataDocument]
hyperdataDocumentFromFrameWrite paragraphSize (HyperdataFrame { _hf_base, _hf_frame_id }, contents) = hyperdataDocumentFromFrameWrite paragraphSize (HyperdataFrame { _hf_base, _hf_frame_id }, contents) =
case parseLines contents of case parseLines contents of
......
...@@ -28,7 +28,8 @@ import qualified Data.List as List ...@@ -28,7 +28,8 @@ import qualified Data.List as List
-- https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/331 -- https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/331
-- Authors : default : anonymous ; except if the following line is encountered ^@@authors: FirstName1, LastName1 ; FirstName2, LastName2 ; etc. -- Authors : default : anonymous ; except if the following line is encountered
-- ^authors: FirstName1, LastName1 ; FirstName2, LastName2 ; etc.
-- date : default : date of last change except if the following line is encountered ^@@date: 2021-09-10 -- date : default : date of last change except if the following line is encountered ^@@date: 2021-09-10
-- source: Name of the root node except if the following line is encountered ^@@source: -- source: Name of the root node except if the following line is encountered ^@@source:
-- By default, 1 framawrite node = 1 document. Option for further developments: allow to give a level at generation for the split within framawrite node : : -- By default, 1 framawrite node = 1 document. Option for further developments: allow to give a level at generation for the split within framawrite node : :
......
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