import Gargantext.Database.Flow (flowCorpusSearchInDatabase)
import Gargantext.Database.Types.Node (CorpusId)
import Gargantext.Prelude
+import Gargantext.Prelude.Utils (hash)
import Servant
import Test.QuickCheck (elements)
import Test.QuickCheck.Arbitrary
data Query = Query { query_query :: Text
, query_corpus_id :: Int
+ , query_files_id :: [Text]
}
deriving (Eq, Show, Generic)
instance Arbitrary Query where
- arbitrary = elements [ Query q n
+ arbitrary = elements [ Query q n fs
| q <- ["a","b"]
, n <- [0..10]
+ , fs <- map (map hash) [["a","b"], ["c","d"]]
]
-instance ToSchema Query
+instance ToSchema Query where
+ declareNamedSchema =
+ genericDeclareNamedSchema
+ defaultSchemaOptions {fieldLabelModifier = \fieldLabel -> drop 6 fieldLabel}
+
type Api = Summary "New Corpus endpoint"
api :: FlowCmdM env err m => Query -> m CorpusId
-api (Query q _) = do
+api (Query q _ _) = do
cId <- flowCorpusSearchInDatabase "user1" EN q
pure cId