Last active
December 16, 2015 07:09
-
-
Save jonstorer/5396906 to your computer and use it in GitHub Desktop.
Give the people their points!! Find challenges from labs members and give them their points!!
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
member_ids = Member.where(:lab => true).only(:_id).map(&:id) | |
after = Date.parse('10/4/2013').to_time.at_beginning_of_day | |
before = Award.where(:created_at.gt => after, :brand_id => nil, :points => Game.int_var('challenge_points_for_each_awardable_view'), :reason => 'Someone checked out your Web Share').asc(:created_at).last.created_at | |
def complete_award(challenge) | |
challenge.award_and_complete if challenge.unique_views_count >= WebShare.min_challenge_view_count_for_completion | |
end | |
def view_awards(challenge) | |
[challenge.unique_views_count, Challenge.max_awardable_views].min.times{ challenge.award_for_event(:visitor_unique_view) } | |
end | |
member_ids.each_slice(10){|ids| Challenge.where(:member_id.in => ids).between(:created_at => after..before).each{|c| view_awards(c); complete_award(c) }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment