Commit ccdec52e authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[document-export] some code cleanup

parent cc2be9dd
......@@ -14,9 +14,7 @@ module Gargantext.API.Node.Document.Export
import qualified Data.ByteString.Lazy.Char8 as BSC
import Data.Csv (encodeDefaultOrderedByName)
import qualified Data.Text as T
--import qualified Data.Text.Conversions as TC
import qualified Data.Text.Encoding as TE
import qualified Data.Text.IO as T
import Data.Version (showVersion)
import Gargantext.API.Node.Document.Export.Types
import Gargantext.API.Prelude (GargNoServer, GargServer)
......@@ -40,14 +38,9 @@ getDocumentsJSON :: UserId
-> DocId
-> GargNoServer DocumentExport
getDocumentsJSON uId pId = do
printDebug "[getDocuments] pId" pId
mcId <- getClosestParentIdByType pId NodeCorpus
let cId = maybe (panic "[G.A.N.D.Export] Node has no parent") identity mcId
printDebug "[getDocuments] cId" cId
--docs <- getDocumentsWithParentId cId -- NodeDocument (Proxy :: Proxy HyperdataDocument)
docs <- runViewDocuments cId False Nothing Nothing Nothing Nothing
--printDebug "[getDocuments] got docs" docs
--de_docs <- mapM mapFacetDoc docs
pure $ DocumentExport { _de_documents = mapFacetDoc <$> docs
, _de_garg_version = T.pack $ showVersion PG.version }
where
......@@ -74,16 +67,7 @@ getDocumentsCSV :: UserId
-> GargNoServer T.Text -- [Document]
getDocumentsCSV uId pId = do
DocumentExport { _de_documents } <- getDocumentsJSON uId pId
printDebug "[getDocumentsCSV] documents" $ _d_document <$> head _de_documents
--let ret = T.pack $ BSC.unpack $ encodeDefaultOrderedByName _de_documents
--let ret = TC.convertText $ encodeDefaultOrderedByName _de_documents
let ret = TE.decodeUtf8 $ BSC.toStrict $ encodeDefaultOrderedByName _de_documents
--printDebug "[getDocumentsCSV] ret" ret
liftBase $ T.writeFile "/tmp/out.csv" ret
--liftBase $ BSC.writeFile "/tmp/out.csv" $ encodeDefaultOrderedByName _de_documents
pure ret
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