[refactor] some more record syntax refactorign

parent 67bc405e
...@@ -21,7 +21,7 @@ import Data.Maybe (catMaybes) ...@@ -21,7 +21,7 @@ import Data.Maybe (catMaybes)
import Data.Text (Text) import Data.Text (Text)
import Data.List (replicate, null) import Data.List (replicate, null)
import Data.Aeson import Data.Aeson
import Data.Swagger import Data.Swagger hiding (title, url)
import GHC.Generics (Generic) import GHC.Generics (Generic)
import Servant import Servant
import Test.QuickCheck (elements) import Test.QuickCheck (elements)
...@@ -107,13 +107,15 @@ publicNodes = do ...@@ -107,13 +107,15 @@ publicNodes = do
-- http://localhost:8008/api/v1.0/node/23543/file/download<Paste> -- http://localhost:8008/api/v1.0/node/23543/file/download<Paste>
-- http://localhost:8000/images/Gargantextuel-212x300.jpg -- http://localhost:8000/images/Gargantextuel-212x300.jpg
toPublicData :: Text -> (Node HyperdataFolder, [NodeId]) -> Maybe PublicData toPublicData :: Text -> (Node HyperdataFolder, [NodeId]) -> Maybe PublicData
toPublicData base (n , mn) = PublicData <$> (hd ^? (_Just . hf_data . cf_title)) toPublicData base (n , mn) = do
<*> (hd ^? (_Just . hf_data . cf_desc )) title <- (hd ^? (_Just . hf_data . cf_title))
<*> (Just $ url' mn) -- "images/Gargantextuel-212x300.jpg" abstract <- (hd ^? (_Just . hf_data . cf_desc ))
<*> (Just $ url' mn) img <- (Just $ url' mn) -- "images/Gargantextuel-212x300.jpg"
<*> Just (cs $ show $ utc2year (n^.node_date)) url <- (Just $ url' mn)
<*> (hd ^? (_Just . hf_data . cf_query)) date <- Just (cs $ show $ utc2year (n^.node_date))
<*> (hd ^? (_Just . hf_data . cf_authors)) database <- (hd ^? (_Just . hf_data . cf_query))
author <- (hd ^? (_Just . hf_data . cf_authors))
pure $ PublicData { .. }
where where
hd = head hd = head
$ filter (\(HyperdataField cd _ _) -> cd == JSON) $ filter (\(HyperdataField cd _ _) -> cd == JSON)
...@@ -150,13 +152,13 @@ instance Arbitrary PublicData where ...@@ -150,13 +152,13 @@ instance Arbitrary PublicData where
defaultPublicData :: PublicData defaultPublicData :: PublicData
defaultPublicData = defaultPublicData =
PublicData "Title" PublicData { title = "Title"
(foldl (<>) "" $ replicate 100 "abstract ") , abstract = foldl (<>) "" $ replicate 100 "abstract "
"images/Gargantextuel-212x300.jpg" , img = "images/Gargantextuel-212x300.jpg"
"https://.." , url = "https://.."
"YY/MM/DD" , date = "YY/MM/DD"
"database" , database = "database"
"Author" , author = "Author" }
......
...@@ -86,7 +86,11 @@ instance ToSchema TableQuery where ...@@ -86,7 +86,11 @@ instance ToSchema TableQuery where
declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "tq_") declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "tq_")
instance Arbitrary TableQuery where instance Arbitrary TableQuery where
arbitrary = elements [TableQuery 0 10 DateAsc Docs "electrodes"] arbitrary = elements [TableQuery { tq_offset = 0
, tq_limit = 10
, tq_orderBy = DateAsc
, tq_view = Docs
, tq_query = "electrodes" }]
tableApi :: NodeId -> GargServer TableApi tableApi :: NodeId -> GargServer TableApi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment