[sqlite] replace putText with logLocM

Also, no need for `liftBase` in `getCorpusSQLite`.
parent 3e49fe87
Pipeline #7509 passed with stages
in 39 minutes and 56 seconds
......@@ -87,13 +87,14 @@ getCorpus cId = Named.CorpusExportAPI {
, _c_hash = hash $ List.map DocumentExport._d_hash $ Map.elems r }
getCorpusSQLite :: (CES.MonadMask m, IsGargServer env err m)
getCorpusSQLite :: ( CES.MonadMask m
, IsGargServer env err m)
=> CorpusId
-> Maybe ListId
-> m (Headers '[Header "Content-Disposition" Text] CorpusSQLite)
getCorpusSQLite cId lId = do
corpusSQLiteData <- mkCorpusSQLiteData cId lId
corpusSQLite <- liftBase $ mkCorpusSQLite corpusSQLiteData
corpusSQLite <- mkCorpusSQLite corpusSQLiteData
pure $ addHeader ("attachment; filename=GarganText_corpus-" <> pack (show cId) <> ".sqlite")
$ corpusSQLite
......
......@@ -8,6 +8,7 @@ Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
module Gargantext.API.Node.Corpus.Export.Utils
......@@ -46,6 +47,7 @@ import Gargantext.Database.Query.Table.NodeContext (selectDocNodes)
import Gargantext.Database.Query.Table.Node.Error (HasNodeError)
import Gargantext.Database.Query.Table.Node.Select (selectNodesWithUsername)
import Gargantext.Prelude
import Gargantext.System.Logging (logLocM, LogLevel(..), MonadLogger)
import Paths_gargantext qualified as PG -- cabal magic build module
import Prelude qualified
import System.Directory (removeDirectoryRecursive)
......@@ -122,13 +124,14 @@ mkCorpusSQLiteData cId lId = do
mkCorpusSQLite :: ( CES.MonadMask m
, MonadBase IO m )
, MonadBase IO m
, MonadLogger m )
=> CorpusSQLiteData
-> m CorpusSQLite
mkCorpusSQLite (CorpusSQLiteData { .. }) = withTempSQLiteDir $ \(fp, _fname, fpath) -> liftBase $ do
putText $ "[mkCorpusSQLite] listId: " <> show _csd_lId
putText $ "[mkCorpusSQLite] fp: " <> show fp
mkCorpusSQLite (CorpusSQLiteData { .. }) = withTempSQLiteDir $ \(fp, _fname, fpath) -> do
$(logLocM) DEBUG $ "listId: " <> show _csd_lId
$(logLocM) DEBUG $ "fp: " <> show fp
liftBase $ do
S.withConnection fpath $ \conn -> do
-- better performance
-- https://kerkour.com/sqlite-for-servers
......
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