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