]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Viz/Chart.hs
Fix some warnings
[gargantext.git] / src / Gargantext / Viz / Chart.hs
1 {-|
2 Module : Gargantext.Viz.Chart
3 Description : Graph utils
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 -}
11
12 {-# LANGUAGE NoImplicitPrelude #-}
13 {-# LANGUAGE TemplateHaskell #-}
14 {-# LANGUAGE DeriveGeneric #-}
15 {-# LANGUAGE RankNTypes #-}
16
17 module Gargantext.Viz.Chart
18 where
19
20
21 import Data.Text (Text)
22 import Data.List (unzip, sortOn)
23 import Data.Map (toList)
24 import GHC.Generics (Generic)
25 import Gargantext.Prelude
26 import Gargantext.Database.Schema.NodeNode (selectDocsDates)
27 import Gargantext.Database.Utils
28 import Gargantext.Database.Types.Node (CorpusId)
29 import Gargantext.Text.Metrics.Count (occurrencesWith)
30
31
32 data Chart = ChartHisto | ChartScatter | ChartPie
33 deriving (Generic)
34
35 -- TODO use UTCTime
36 data Histo = Histo { histo_dates :: [Text]
37 , histo_count :: [Int]
38 }
39 deriving (Generic)
40
41 histoData :: CorpusId -> Cmd err Histo
42 histoData cId = do
43 dates <- selectDocsDates cId
44 let (ls, css) = unzip
45 $ sortOn fst
46 $ toList
47 $ occurrencesWith identity dates
48 pure (Histo ls css)
49