Last active
May 4, 2016 20:27
-
-
Save ryanpbrewster/dc144cb4e5cdaba91f379bd72dc1d2fe 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
| 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