Commit 381d49db authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[ngrams] WIP CSV export work

parent 6078ebf1
Pipeline #3512 failed with stage
in 49 minutes and 59 seconds
......@@ -58,13 +58,15 @@ import qualified Data.Map as Map
import qualified Data.Set as Set
import qualified Data.Text as Text
import qualified Data.Vector as Vec
import qualified Gargantext.Utils.Servant as GUS
import qualified Prelude
import qualified Protolude as P
------------------------------------------------------------------------
type GETAPI = Summary "Get List"
:> "lists"
:> Capture "listId" ListId
:> Get '[JSON, HTML] (Headers '[Header "Content-Disposition" Text] NgramsList)
:> Capture "fileType" Text
:> Get '[JSON, GUS.CSV, HTML] (Headers '[Header "Content-Disposition" Text] NgramsList)
getApi :: GargServer GETAPI
getApi = get
......@@ -95,8 +97,8 @@ csvApi = csvPostAsync
------------------------------------------------------------------------
get :: HasNodeStory env err m =>
ListId -> m (Headers '[Header "Content-Disposition" Text] NgramsList)
get lId = do
ListId -> Text -> m (Headers '[Header "Content-Disposition" Text] NgramsList)
get lId "JSON" = do
lst <- getNgramsList lId
let (NodeId id') = lId
return $ addHeader (concat [ "attachment; filename=GarganText_NgramsList-"
......@@ -104,6 +106,15 @@ get lId = do
, ".json"
]
) lst
get lId "CSV" = do
lst <- getNgramsList lId
let (NodeId id') = lId
return $ addHeader (concat [ "attachment; filename=GarganText_NgramsList-"
, pack $ show id'
, ".csv"
]
) lst
get lId _ = get lId "JSON"
------------------------------------------------------------------------
-- TODO : purge list
......
......@@ -71,10 +71,10 @@ toTermList lt nt nl = toTermList' lt <$> Map.lookup nt nl
children' = catMaybes
$ map (\(t,nre) -> (,) <$> view nre_root nre
<*> Just (map toTerm $ [t]
<*> Just (map toTerm $ [t]
<> (unMSet $ view nre_children nre)
)
) children
) children
------------------------------------------
patchMSet_toList :: (Ord a, Hashable a) => PatchMSet a -> [(a,AddRem)]
......
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