]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Viz/Types.hs
[FIX MERGE]
[gargantext.git] / src / Gargantext / Viz / Types.hs
1 {-# LANGUAGE DeriveGeneric #-}
2 {-# LANGUAGE FlexibleContexts #-}
3 {-# LANGUAGE NoImplicitPrelude #-}
4 {-# LANGUAGE OverloadedStrings #-}
5 {-# LANGUAGE RankNTypes #-}
6 {-# LANGUAGE TemplateHaskell #-}
7
8 module Gargantext.Viz.Types where
9
10 import Data.Aeson.TH (deriveJSON)
11 import Data.Swagger
12 import Data.Text (Text)
13 import GHC.Generics (Generic)
14 import Protolude
15 import Test.QuickCheck (elements)
16 import Test.QuickCheck.Arbitrary (Arbitrary, arbitrary)
17
18 import Gargantext.Core.Utils.Prefix (unPrefix, unPrefixSwagger)
19
20 ---------------
21 -- | Chart | --
22 ---------------
23
24 data Chart = ChartHisto | ChartScatter | ChartPie
25 deriving (Generic)
26
27 -- TODO use UTCTime
28 data Histo = Histo { histo_dates :: ![Text]
29 , histo_count :: ![Int]
30 }
31 deriving (Show, Generic)
32
33 instance ToSchema Histo where
34 declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "histo_")
35 instance Arbitrary Histo
36 where
37 arbitrary = elements [ Histo ["2012"] [1]
38 , Histo ["2013"] [1]
39 ]
40 deriveJSON (unPrefix "histo_") ''Histo