Commit 233539c3 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] Hyperdata of Documents

parent bc39b467
......@@ -141,9 +141,9 @@ graphAPI _ _ = liftIO $ textFlow (Mono EN) (Contexts contextText)
instance HasTreeError ServantErr where
_TreeError = prism' mk (const Nothing) -- Note a prism
where
mk NoRoot = err404 { errBody = "Root node not found" }
mk NoRoot = err404 { errBody = "Root node not found" }
mk EmptyRoot = err500 { errBody = "Root node should not be empty" }
mk TooManyRoots = err500 { errBody = "Too many root nodes" }
mk TooManyRoots = err500 { errBody = "Too many root nodes" }
type TreeAPI = Get '[JSON] (Tree NodeTree)
treeAPI :: Connection -> NodeId -> Server TreeAPI
......
......@@ -104,14 +104,12 @@ home = map node_id <$> Cmd (ReaderT (getNodesWithParentId 0 Nothing))
ls :: PWD -> Cmd [Node Value]
ls = get
tree :: PWD -> Cmd [Node Value]
tree p = do
ns <- get p
children <- mapM (\n -> get [node_id n]) ns
pure $ ns <> concat children
-- | TODO
post :: PWD -> [NodeWrite'] -> Cmd Int64
post [] _ = pure 0
......@@ -164,8 +162,6 @@ postAnnuaire corpusName title ns = do
--------------------------------------------------------------
-- Tests
--------------------------------------------------------------
get' :: PWD -> IO [Node Value]
get' = runCmd' . get
......
......@@ -70,23 +70,22 @@ $(deriveJSON (unPrefix "status_") ''Status)
instance Arbitrary Status where
arbitrary = Status <$> arbitrary <*> arbitrary <*> arbitrary
------------------------------------------------------------------------
data StatusV3 = StatusV3 { statusV3_error :: Maybe Text
, statusV3_action :: Maybe Text
} deriving (Show, Generic)
$(deriveJSON (unPrefix "statusV3_") ''StatusV3)
------------------------------------------------------------------------
------------------------------------------------------------------------
data HyperdataDocumentV3 = HyperdataDocumentV3 { hyperdataDocumentV3_publication_day :: Maybe Int
, hyperdataDocumentV3_language_iso2 :: Maybe Text
, hyperdataDocumentV3_publication_second :: Maybe Int
, hyperdataDocumentV3_publication_minute :: Maybe Int
, hyperdataDocumentV3_error :: Maybe Text
, hyperdataDocumentV3_publication_month :: Maybe Int
, hyperdataDocumentV3_publication_hour :: Maybe Int
, hyperdataDocumentV3_error :: Maybe Text
, hyperdataDocumentV3_language_iso3 :: Maybe Text
, hyperdataDocumentV3_publication_second :: Maybe Int
, hyperdataDocumentV3_authors :: Maybe Text
, hyperdataDocumentV3_publication_year :: Maybe Int
, hyperdataDocumentV3_publication_date :: Maybe Text
......@@ -96,7 +95,6 @@ data HyperdataDocumentV3 = HyperdataDocumentV3 { hyperdataDocumentV3_publication
, hyperdataDocumentV3_source :: Maybe Text
, hyperdataDocumentV3_abstract :: Maybe Text
, hyperdataDocumentV3_title :: Maybe Text
, hyperdataDocumentV3_publication_hour :: Maybe Int
} deriving (Show, Generic)
$(deriveJSON (unPrefix "hyperdataDocumentV3_") ''HyperdataDocumentV3)
......
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