Last active
February 14, 2019 18:54
-
-
Save eduardopoleo/55989a3624546c402b4b171502544cc2 to your computer and use it in GitHub Desktop.
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
def recommended_experiences(experiences_limit) | |
experiences = current_contact | |
.available_experiences | |
.includes(challenges: :attachments) | |
experience_payloads = [] | |
experiences.find_each do |experience| | |
payload = experience_payload(experience) | |
empty = payload[:total_challenge_count].zero? | |
experience_payloads << payload unless empty | |
break if experience_payloads.size == experiences_limit | |
end | |
experience_payloads | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This read better but I do not think it's a great solution cuz
find_each
could potentially do a bunch of queries.