Last active
March 22, 2021 22:29
-
-
Save jchapuis/8d12cb3b56578b2c42f378631b946d6b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getBlocksForResource[F[_, _]: BifunctorMonadError: Bilogger] | |
(resourceID: ResourceID, timeFilter: TimeFilter) | |
(implicit resourceRepo: ResourceRepo[F], blockRepo: BlockRepo[F]): F[ResourceBlockError, List[Block]] = | |
(for { | |
resource <- resourceRepo.get(resourceID) | |
blocks <- blockRepo.blocksForResource(resource, timeFilter) | |
_ <- F.info(show"Successfully generated ${blocks.size} blocks for resource $resourceID in interval $timeFilter") | |
} yield blocks).onLeft { | |
case repositoryError: RepositoryError => F.error(repositoryError.message) | |
case blockError: BlockError => F.error(blockError.message) | |
case notFound: ResourceNotFound => F.info(notFound.message) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment