Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
class TalksAdvisor(private val searchTalks: SearchTalks,
private val recommendations: Recommendations,
private val profiles: Profiles) : RecommendTalks {
override fun to(userId: String): Recommendation {
val profile = profiles.fetch(userId) ?: throw ProfileNotFoundException(userId)
return recommendTalksSatisfying(profile.preferences)
override fun satisfying(guestCriteria: GuestCriteria): Recommendation {
return recommendTalksSatisfying(guestCriteria as Criteria)
private fun recommendTalksSatisfying(criteria: Criteria): Recommendation {
val talks = retrieveTalksSatisfying(criteria)
return = criteria, talks = talks))
private fun retrieveTalksSatisfying(criteria: Criteria): Set<Talk> {
return searchTalks.forTopics(criteria.topics)
.filter { criteria.hasTalkFormat(it.format) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment