Count API part of Gargantext.
-}
-{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
-
-{-# LANGUAGE NoImplicitPrelude #-}
-{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
-{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveAnyClass #-}
-{-# LANGUAGE OverloadedStrings #-}
module Gargantext.API.Count
where
-
-import GHC.Generics (Generic)
-import Prelude (Bounded, Enum, minBound, maxBound)
-
import Data.Aeson hiding (Error)
import Data.Aeson.TH (deriveJSON)
-import Data.Eq (Eq())
import Data.Either
-import Data.List (repeat, permutations)
+import Data.List (permutations)
import Data.Swagger
import Data.Text (Text, pack)
-
+import GHC.Generics (Generic)
+import Gargantext.Core.Utils.Prefix (unPrefix, unPrefixSwagger)
+import Gargantext.Prelude
import Servant
-import Test.QuickCheck.Arbitrary
import Test.QuickCheck (elements)
--- import Control.Applicative ((<*>))
-
-import Gargantext.Prelude
-import Gargantext.Core.Utils.Prefix (unPrefix)
+import Test.QuickCheck.Arbitrary
-----------------------------------------------------------------------
+-- TODO-ACCESS: CanCount
+-- TODO-EVENTS: No events as this is a read only query.
type CountAPI = Post '[JSON] Counts
-----------------------------------------------------------------------
queries :: [QueryBool]
queries = [QueryBool (pack "(X OR X') AND (Y OR Y') NOT (Z OR Z')")]
+--queries = [QueryBool (pack "(X + X') * (Y + Y') - (Z + Z')")]
instance Arbitrary QueryBool where
arbitrary = elements queries
, n <- take 10 $ permutations scrapers
]
-instance ToSchema Query
+instance ToSchema Query where
+ declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "query_")
+
-----------------------------------------------------------------------
type Code = Integer
type Error = Text
$(deriveJSON (unPrefix "count_") ''Count)
-instance ToSchema Count
+instance ToSchema Count where
+ declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "count_")
--instance Arbitrary Count where
-- arbitrary = Count <$> arbitrary <*> arbitrary <*> arbitrary
-----------------------------------------------------------------------
-count :: Query -> Handler Counts
+count :: Monad m => Query -> m Counts
count _ = undefined