Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Additional checks in the all-important Group migration script

  • Loading branch information...
commit ef2e2dc56efd0a74cac18cd1a7f83f79ab2d8b8b 1 parent 43f3d5a
@cthielen cthielen authored
View
2  config/initializers/last_updated.rb
@@ -1 +1 @@
-LAST_UPDATED = 'Mon Feb 24 19:39:31 PST 2014'
+LAST_UPDATED = 'Mon Feb 24 19:39:44 PST 2014'
View
33 lib/tasks/group_tasks.rake
@@ -34,4 +34,37 @@ namespace :group do
Authorization.ignore_access_control(false)
end
+
+ desc 'Recalculate the rule-based members of a specific group.'
+ task :recalculate, [:group_id] => :environment do |t, args|
+ unless args[:group_id]
+ puts "You must specify a group ID to recalculate."
+ exit
+ end
+
+ g = Group.find_by_id(args[:group_id])
+ unless g
+ puts "Could not find a group with ID #{args[:group_id]}."
+ exit
+ end
+
+ Authorization.ignore_access_control(true)
+
+ puts "Group (#{g.id}, #{g.name}) has #{g.rules.length} rules."
+
+ # Recalculate the group's rule caches
+ g.rules.each do |rule|
+ old_count = rule.results.length
+ rule.resolve!
+ rule.reload
+ puts "\tGroupRule ##{rule.id} (#{rule.column} #{rule.condition} #{rule.value}) went from #{old_count} to #{rule.results.length} results"
+ end
+
+ old_count = g.members.length
+ g.recalculate_members!
+ g.reload
+ puts "\tGroup ##{g.id} (#{g.name}) went from #{old_count} to #{g.members.length} members"
+
+ Authorization.ignore_access_control(false)
+ end
end
View
4 lib/tasks/organization_tasks.rake
@@ -214,6 +214,10 @@ namespace :organization do
end
end
+ GroupRule.where(column: 'ou').each do |rule|
+ puts "WARNING: A rule exists for 'ou' #{rule.condition} '#{rule.value}'. If this is a group that should have been converted, the name likely couldn't be matched exactly and you will need to migrate the rule yourself. It is attached to group #{rule.group.id}, #{rule.group.name}."
+ end
+
Authorization.ignore_access_control(false)
end
Please sign in to comment.
Something went wrong with that request. Please try again.