]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/API/Metrics.hs
[FACTO] VIZ.APIS
[gargantext.git] / src / Gargantext / API / Metrics.hs
1 {-|
2 Module : Gargantext.API.Metrics
3 Description : Server API
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 Metrics API
11
12 -}
13
14 {-# OPTIONS_GHC -fno-warn-orphans #-}
15
16 {-# LANGUAGE DataKinds #-}
17 {-# LANGUAGE DeriveGeneric #-}
18 {-# LANGUAGE FlexibleContexts #-}
19 {-# LANGUAGE NoImplicitPrelude #-}
20 {-# LANGUAGE OverloadedStrings #-}
21 {-# LANGUAGE RankNTypes #-}
22 {-# LANGUAGE TemplateHaskell #-}
23 {-# LANGUAGE TypeOperators #-}
24
25 module Gargantext.API.Metrics
26 where
27
28 import Data.Text (Text)
29 import GHC.Generics (Generic)
30 import Gargantext.Prelude
31 import Data.Aeson.TH (deriveJSON)
32 import Test.QuickCheck.Arbitrary (Arbitrary, arbitrary)
33 import Gargantext.Core.Types (ListType(..))
34 import Gargantext.Core.Utils.Prefix (unPrefix)
35 import Data.Swagger
36
37
38 data Metrics = Metrics
39 { metrics_data :: [Metric]}
40 deriving (Generic, Show)
41
42 instance ToSchema Metrics
43 instance Arbitrary Metrics
44 where
45 arbitrary = Metrics <$> arbitrary
46
47 data Metric = Metric
48 { m_label :: !Text
49 , m_x :: !Double
50 , m_y :: !Double
51 , m_cat :: !ListType
52 } deriving (Generic, Show)
53
54 instance ToSchema Metric
55 instance Arbitrary Metric
56 where
57 arbitrary = Metric <$> arbitrary
58 <*> arbitrary
59 <*> arbitrary
60 <*> arbitrary
61
62 deriveJSON (unPrefix "metrics_") ''Metrics
63 deriveJSON (unPrefix "m_") ''Metric
64
65