APOATM4XGEQZHANT5IY57SKA2QEQ34BZHGNTRAV5KRVPEHUCDYKAC
7TQPQW3NPNUK6CMTOT5ZE4MDENJ5SUOJ2VF2M4JGKHLZHXVX4F3QC
NAFJ6RB3KYDBSTSNB3WQSVUQEPUGG2RZCBWRF4XNT2UKSOXDNMDQC
Z5KNL332YCRMHKU3NG7YWNLUCNHKSLXBZ3O22FSS47MNVXU2FDLAC
PPW6ROC5U7FZCJCH2RX7UJ3PJYNPUMNEZ6KKO3375VFRUM4VT3VQC
QAC2QJ32ZLAK25KJ7SWT27WOZKD2MMDE7OZPHIRRFP2W2QZW7PBAC
GLQSD33YYNRDK23R7W2LEIXODI4N5JD3RHX5VMRR5WPMSVMS333QC
derive instance contributorNewtype :: Newtype (Contributor' a) _
derive instance contributorFunctor :: Functor Contributor'
instance contributorFoldable :: Foldable Contributor' where
foldr f b (Contributor' p) = f (p.joinedOn) b
foldl f b (Contributor' p) = f b (p.joinedOn)
foldMap = foldMapDefaultR
instance contributorTraversable :: Traversable Contributor' where
traverse f (Contributor' p) =
Contributor' <<< (\b -> p { joinedOn = b }) <$> f (p.joinedOn)
sequence = traverse identity
type ProjectDetailJson date =
{ project :: Project' date
, contributors :: Array (Contributor' date)
}
derive instance projectDetailNewtype :: Newtype (ProjectDetail' a) _
derive instance projectDetailFunctor :: Functor ProjectDetail'
instance projectDetailFoldable :: Foldable ProjectDetail' where
foldr f b (ProjectDetail' p) = foldr f (foldr f b (p.project)) (Compose p.contributors)
foldl f b (ProjectDetail' p) = foldl f (foldl f b (p.project)) (Compose p.contributors)
foldMap = foldMapDefaultR
instance projectDetailTraversable :: Traversable ProjectDetail' where
traverse f (ProjectDetail' p) =
projectDetail <$> traverse f p.project
<*> (map unwrap $ traverse f (Compose p.contributors))
sequence = traverse identity
-- getProjectDetail :: ProjectId -> Aff (Maybe ProjectDetail)
-- getProjectDetail pid = do
-- response <- get RF.json ("/api/user/projects/" <> pidStr pid)
-- EC.liftEffect
-- <<< map (\dt -> ProjectDetail' {
-- project: dt.project,
-- contributors: M.fromFoldable $ map (\c -> (Tuple c.userId c)) dt.contributors
-- })
-- $ parsed
getProjectDetail :: ProjectId -> Aff (Either APIError (Maybe ProjectDetail))
getProjectDetail pid = do
response <- get RF.json ("/api/user/projects/" <> pidStr pid <> "/detail")
let parsed :: ExceptT APIError Effect (Maybe (ProjectDetail' Instant))
parsed = parseDatedResponseMay response
EC.liftEffect
<<< runExceptT
<<< map (map (map toDateTime))
$ parsed