Mercurial > hg > soundsoftware-site
comparison app/models/watcher.rb @ 1517:dffacf8a6908 redmine-2.5
Update to Redmine SVN revision 13367 on 2.5-stable branch
author | Chris Cannam |
---|---|
date | Tue, 09 Sep 2014 09:29:00 +0100 |
parents | e248c7af89ec |
children |
comparison
equal
deleted
inserted
replaced
1516:b450a9d58aed | 1517:dffacf8a6908 |
---|---|
40 def self.prune(options={}) | 40 def self.prune(options={}) |
41 if options.has_key?(:user) | 41 if options.has_key?(:user) |
42 prune_single_user(options[:user], options) | 42 prune_single_user(options[:user], options) |
43 else | 43 else |
44 pruned = 0 | 44 pruned = 0 |
45 User.where("id IN (SELECT DISTINCT user_id FROM #{table_name})").all.each do |user| | 45 User.where("id IN (SELECT DISTINCT user_id FROM #{table_name})").each do |user| |
46 pruned += prune_single_user(user, options) | 46 pruned += prune_single_user(user, options) |
47 end | 47 end |
48 pruned | 48 pruned |
49 end | 49 end |
50 end | 50 end |
58 private | 58 private |
59 | 59 |
60 def self.prune_single_user(user, options={}) | 60 def self.prune_single_user(user, options={}) |
61 return unless user.is_a?(User) | 61 return unless user.is_a?(User) |
62 pruned = 0 | 62 pruned = 0 |
63 where(:user_id => user.id).all.each do |watcher| | 63 where(:user_id => user.id).each do |watcher| |
64 next if watcher.watchable.nil? | 64 next if watcher.watchable.nil? |
65 | |
66 if options.has_key?(:project) | 65 if options.has_key?(:project) |
67 next unless watcher.watchable.respond_to?(:project) && watcher.watchable.project == options[:project] | 66 unless watcher.watchable.respond_to?(:project) && |
67 watcher.watchable.project == options[:project] | |
68 next | |
69 end | |
68 end | 70 end |
69 | |
70 if watcher.watchable.respond_to?(:visible?) | 71 if watcher.watchable.respond_to?(:visible?) |
71 unless watcher.watchable.visible?(user) | 72 unless watcher.watchable.visible?(user) |
72 watcher.destroy | 73 watcher.destroy |
73 pruned += 1 | 74 pruned += 1 |
74 end | 75 end |