Commit 617998d737b15d3bea32bde76d2b456be90e8f17
1 parent
5df22207
Exists in
master
and in
1 other branch
Fix identation
Showing
1 changed file
with
12 additions
and
12 deletions
Show diff stats
db/migrate/20150930132305_move_points_category_to_categorization_tables.rb
1 | class MovePointsCategoryToCategorizationTables < ActiveRecord::Migration | 1 | class MovePointsCategoryToCategorizationTables < ActiveRecord::Migration |
2 | def up | 2 | def up |
3 | - Merit::PointRules::AVAILABLE_RULES.each do |name, setting| | ||
4 | - type = GamificationPlugin::PointsType.create(name: name.to_s, description: setting[:description]) | ||
5 | - env = Environment.default | 3 | + Merit::PointRules::AVAILABLE_RULES.each do |name, setting| |
4 | + type = GamificationPlugin::PointsType.create(name: name.to_s, description: setting[:description]) | ||
5 | + env = Environment.default | ||
6 | next if env.blank? | 6 | next if env.blank? |
7 | - settings = Noosfero::Plugin::Settings.new(env, GamificationPlugin) | 7 | + settings = Noosfero::Plugin::Settings.new(env, GamificationPlugin) |
8 | weight = settings.settings.fetch(:point_rules, {}).fetch(name.to_s, {}).fetch('weight', setting[:default_weight]).to_i | 8 | weight = settings.settings.fetch(:point_rules, {}).fetch(name.to_s, {}).fetch('weight', setting[:default_weight]).to_i |
9 | - cat = GamificationPlugin::PointsCategorization.create(point_type_id: type.id, weight: weight) | ||
10 | - Merit::Score.update_all "category = '#{cat.id}'", category: name | ||
11 | - end | 9 | + cat = GamificationPlugin::PointsCategorization.create(point_type_id: type.id, weight: weight) |
10 | + Merit::Score.update_all "category = '#{cat.id}'", category: name | ||
11 | + end | ||
12 | end | 12 | end |
13 | 13 | ||
14 | def down | 14 | def down |
15 | - GamificationPlugin::PointsCategorization.all.each do |categorization| | ||
16 | - Merit::Score.update_all "category = '#{categorization.point_type.name}'", category: categorization.id.to_s | ||
17 | - categorization.point_type.destroy | ||
18 | - categorization.destroy | ||
19 | - end | 15 | + GamificationPlugin::PointsCategorization.all.each do |categorization| |
16 | + Merit::Score.update_all "category = '#{categorization.point_type.name}'", category: categorization.id.to_s | ||
17 | + categorization.point_type.destroy | ||
18 | + categorization.destroy | ||
19 | + end | ||
20 | end | 20 | end |
21 | end | 21 | end |