Compare View
Commits (2)
-
Fix pontuation check and add check for badges See merge request !5
Showing
1 changed file
Show diff stats
script/check_merit_actions_vs_points.rb
... | ... | @@ -89,10 +89,16 @@ 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 | + conditions = {} | |
93 | + | |
94 | + clean_profiles_file = File.join(Rails.root,'tmp','gamification_clean_profiles.yml') | |
95 | + clean_profiles = YAML.load(File.read(clean_profiles_file)) if File.exist?(File.join(clean_profiles_file)) | |
96 | + clean_profiles = [0] if clean_profiles.nil? | |
97 | + | |
98 | + people_count = environment.people.where(conditions).where("id not in (?)",clean_profiles).count | |
93 | 99 | person_index = 0 |
94 | 100 | puts "Analising environment people" |
95 | - environment.people.find_each(:conditions => conditions) do |person| | |
101 | + environment.people.where("id not in (?)",clean_profiles).find_each(:conditions => conditions) do |person| | |
96 | 102 | person_index += 1 |
97 | 103 | profile_ids = GamificationPlugin::PointsCategorization.uniq.pluck(:profile_id) |
98 | 104 | profile_ids.keep_if { |item| group_control.keys.include?(item) } unless group_control.nil? |
... | ... | @@ -145,7 +151,7 @@ Environment.all.each do |environment| |
145 | 151 | end |
146 | 152 | end |
147 | 153 | if should_and_doesnt_have.size > 0 || should_not_have.size > 0 |
148 | - CSV.open( "gamification_points_out_expectation.csv", 'a' ) do |csv| | |
154 | + CSV.open( "gamification_wrong_badges.csv", 'a' ) do |csv| | |
149 | 155 | [person.identifier, should_and_doesnt_have.join(' | '), should_not_have.join(' | ')] |
150 | 156 | end |
151 | 157 | end |
... | ... | @@ -156,6 +162,7 @@ Environment.all.each do |environment| |
156 | 162 | } |
157 | 163 | |
158 | 164 | puts "Points:" |
165 | + is_profile_clean = true | |
159 | 166 | scope_by_type.each do |type, scope| |
160 | 167 | c = GamificationPlugin::PointsCategorization.for_type(type).where(profile_id: profile_id).joins(:point_type).first |
161 | 168 | points = calc_points c, scope |
... | ... | @@ -169,11 +176,13 @@ Environment.all.each do |environment| |
169 | 176 | CSV.open( "gamification_points_out_expectation.csv", 'a' ) do |csv| |
170 | 177 | [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 | 178 | end |
179 | + is_profile_clean = false | |
172 | 180 | else |
173 | 181 | puts "points fixed for #{c.point_type.name}!" |
174 | 182 | end |
175 | 183 | end |
176 | 184 | end |
185 | + File.open(clean_profiles_file, 'w') {|f| f.write(clean_profiles.push(person.id).to_yaml)} if is_profile_clean | |
177 | 186 | puts |
178 | 187 | end |
179 | 188 | end | ... | ... |