Commit 9b9bf5d8c2d338d3e4f6c1bc0542e4d602acc608

Authored by Leandro Santos
1 parent 5e413c48

use control group

Showing 1 changed file with 13 additions and 4 deletions   Show diff stats
script/process_merit_rules.rb
@@ -68,23 +68,32 @@ Environment.all.each do |environment| @@ -68,23 +68,32 @@ Environment.all.each do |environment|
68 end 68 end
69 69
70 followed_articles_count = article.article_followers.count 70 followed_articles_count = article.article_followers.count
71 - article.article_followers.each_with_index do |af, i| 71 + article.article_followers.each.with_index(1) do |af, i|
72 puts "Analising follow of article '#{article.id}': follow #{i} of #{followed_articles_count}" 72 puts "Analising follow of article '#{article.id}': follow #{i} of #{followed_articles_count}"
73 create_action(af, i, followed_articles_count) 73 create_action(af, i, followed_articles_count)
74 end 74 end
75 end 75 end
76 76
77 - people_count = environment.people.count  
78 - environment.people.each.with_index(1) do |person, person_index| 77 + group_control = YAML.load(File.read(File.join(Rails.root,'tmp','control_group.yml'))) if File.exist?(File.join(Rails.root,'tmp','control_group.yml'))
  78 + conditions = group_control.nil? ? {} : {:identifier => group_control[profile_id]['profiles']}
  79 + people_count = environment.people.where(conditions).count
  80 + person_index = 0
  81 + puts "Analising environment people"
  82 +puts conditions.inspect
  83 + environment.people.find_each(conditions) do |person|
  84 + person_index += 1
  85 + puts "Analising person #{person_index} of #{people_count}"
79 create_action(person, person_index, people_count) 86 create_action(person, person_index, people_count)
80 87
81 vote_count = person.votes.count 88 vote_count = person.votes.count
82 person.votes.each.with_index(1) do |vote, vote_index| 89 person.votes.each.with_index(1) do |vote, vote_index|
  90 + puts "Analising votes #{vote_index} of #{vote_count}"
83 create_action(vote, vote_index, vote_count) 91 create_action(vote, vote_index, vote_count)
84 end 92 end
85 93
86 friendship_count = person.friends.count 94 friendship_count = person.friends.count
87 - person.friends.each_with_index do |friend, index| 95 + person.friends.each.with_index(1) do |friend, index|
  96 + puts "Analising friends #{index} of #{friendship_count}"
88 create_action(friend, index, friendship_count) 97 create_action(friend, index, friendship_count)
89 end 98 end
90 end 99 end