def execute(): Unit = { def shouldCelebrateContribution(before: Long, now: Long): Boolean = (before / THRESHOLD < now / THRESHOLD) && (now % THRESHOLD > 0) User.findAll().foreach(user => { val contribution = User.calcContribution(user.userId) cache.get(user.userId).foreach(before => { if (shouldCelebrateContribution(before, contribution)) { val message = s""" |${contribution / THRESHOLD * THRESHOLD} Contribution! | ${user.name} |$BASE_URL/users/${user.userId}""".stripMargin Slack().post(message) }}) cache.put(user.userId, contribution) })