Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. GeoWatch.remove_indexes
  2. GeoWatch.create_indexes
  3.  
  4. Alert.remove_indexes
  5. Alert.create_indexes
  6.  
  7. GeoWatch.unscoped.all.batch_size(100).each do |gw|
  8. print "GeoWatch[#{gw.id}] ... "
  9.  
  10. alert_criteria = Alert.unscoped.where(geo_watch_id: gw.id)
  11. print "alert_count: #{alert_criteria.count} ... "
  12.  
  13. if gw.state_active?
  14. alert_criteria.update_all(state_enum: Alert.state_active)
  15. puts "active"
  16. next
  17. end
  18.  
  19. alert_criteria.update_all(state_enum: Alert.state_disabled)
  20. puts "DISABLED"
  21. end; "done"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement