Skip to content

Instantly share code, notes, and snippets.

@ryanpbrewster
Last active May 4, 2016 20:27
Show Gist options
  • Select an option

  • Save ryanpbrewster/dc144cb4e5cdaba91f379bd72dc1d2fe to your computer and use it in GitHub Desktop.

Select an option

Save ryanpbrewster/dc144cb4e5cdaba91f379bd72dc1d2fe to your computer and use it in GitHub Desktop.
case class NewPost(userId: Id[User], groupId: Id[Group], postId: Id[Post])
def generateNotifications(activity: Seq[NewPost]): Seq[String] = {
val (allUsers, allGroups, allPosts) = {
val usersIds = activity.map(_.userId).toSet
val groupIds = activity.map(_.groupId).toSet
val postIds = activity.map(_.postId).toSet
(getManyUsersFromDb(userIds), getManyGroupsFromDb(groupIds), getManyPostsFromDb(postIds))
}
activity.map {
case NewPost(userId, groupId, postId) =>
val user = allUsers(userId)
val group = allGroups(libraryId)
val post = allPosts(postId)
s"${user.fullName} shared ${post.title} with ${group.name}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment