Commit 392caf29009d5b406e6a608d403f3972d57947c3
1 parent
bea83c23
Exists in
master
and in
1 other branch
Save the ids of people already checked and skip it on next load
Showing
1 changed file
with
11 additions
and
3 deletions
Show diff stats
script/check_merit_actions_vs_points.rb
| ... | ... | @@ -89,10 +89,15 @@ Environment.all.each do |environment| |
| 89 | 89 | |
| 90 | 90 | 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')) |
| 91 | 91 | conditions = group_control.nil? ? {} : {:identifier => group_control.map{|k,v| v['profiles']}.flatten} |
| 92 | - people_count = environment.people.where(conditions).count | |
| 92 | + | |
| 93 | + clean_profiles_file = File.join(Rails.root,'tmp','gamification_clean_profiles.yml') | |
| 94 | + clean_profiles = YAML.load(File.read(clean_profiles_file)) if File.exist?(File.join(clean_profiles_file)) | |
| 95 | + clean_profiles = [0] if clean_profiles.nil? | |
| 96 | + | |
| 97 | + people_count = environment.people.where(conditions).where("id not in (?)",clean_profiles).count | |
| 93 | 98 | person_index = 0 |
| 94 | 99 | puts "Analising environment people" |
| 95 | - environment.people.find_each(:conditions => conditions) do |person| | |
| 100 | + environment.people.where("id not in (?)",clean_profiles).find_each(:conditions => conditions) do |person| | |
| 96 | 101 | person_index += 1 |
| 97 | 102 | profile_ids = GamificationPlugin::PointsCategorization.uniq.pluck(:profile_id) |
| 98 | 103 | profile_ids.keep_if { |item| group_control.keys.include?(item) } unless group_control.nil? |
| ... | ... | @@ -145,7 +150,7 @@ Environment.all.each do |environment| |
| 145 | 150 | end |
| 146 | 151 | end |
| 147 | 152 | if should_and_doesnt_have.size > 0 || should_not_have.size > 0 |
| 148 | - CSV.open( "gamification_points_out_expectation.csv", 'a' ) do |csv| | |
| 153 | + CSV.open( "gamification_wrong_badges.csv", 'a' ) do |csv| | |
| 149 | 154 | [person.identifier, should_and_doesnt_have.join(' | '), should_not_have.join(' | ')] |
| 150 | 155 | end |
| 151 | 156 | end |
| ... | ... | @@ -156,6 +161,7 @@ Environment.all.each do |environment| |
| 156 | 161 | } |
| 157 | 162 | |
| 158 | 163 | puts "Points:" |
| 164 | + is_profile_clean = true | |
| 159 | 165 | scope_by_type.each do |type, scope| |
| 160 | 166 | c = GamificationPlugin::PointsCategorization.for_type(type).where(profile_id: profile_id).joins(:point_type).first |
| 161 | 167 | points = calc_points c, scope |
| ... | ... | @@ -169,11 +175,13 @@ Environment.all.each do |environment| |
| 169 | 175 | CSV.open( "gamification_points_out_expectation.csv", 'a' ) do |csv| |
| 170 | 176 | [person.identifier, person.name, scope.first.class.base_class.name, profile_name, c.id, c.point_type.name, scope.count*c.weight, person.points(category: c.id.to_s)] |
| 171 | 177 | end |
| 178 | + is_profile_clean = false | |
| 172 | 179 | else |
| 173 | 180 | puts "points fixed for #{c.point_type.name}!" |
| 174 | 181 | end |
| 175 | 182 | end |
| 176 | 183 | end |
| 184 | + File.open(clean_profiles_file, 'w') {|f| f.write(clean_profiles.push(person.id).to_yaml)} if is_profile_clean | |
| 177 | 185 | puts |
| 178 | 186 | end |
| 179 | 187 | end | ... | ... |