Created
August 31, 2020 15:35
-
-
Save rfermontero/9cb9e04d7f8599a312246760f93009d4 to your computer and use it in GitHub Desktop.
influencersEngad.kt
This file contains 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
private fun numberOfLikes(user: User) = user.timeLineMedia.edges.sumBy { it.node.likes.count } | |
private fun numberOfComments(user: User) = user.timeLineMedia.edges.sumBy { it.node.comments.count } | |
private fun calculateEngagement(user: User) = if (user.isPrivate) 0f else | |
BigDecimal((numberOfLikes(user) + numberOfComments(user))) | |
.divide( | |
BigDecimal(user.followers.count), | |
3, | |
RoundingMode.HALF_DOWN | |
) | |
.multiply(BigDecimal.TEN) | |
.toFloat() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment