Commit 4ba4ceaf2b57ffbe82a6cd57ae946db9f5d886fb
1 parent
607528df
Exists in
master
and in
29 other branches
Filter out activities echos from wall
Removes from activities the ActionTracker::Records which are redundants to certain profiles. (ActionItem2402)
Showing
3 changed files
with
5 additions
and
3 deletions
Show diff stats
app/models/community.rb
... | ... | @@ -88,7 +88,7 @@ class Community < Organization |
88 | 88 | end |
89 | 89 | |
90 | 90 | def activities |
91 | - Scrap.find_by_sql("SELECT id, updated_at, '#{Scrap.to_s}' AS klass FROM #{Scrap.table_name} WHERE scraps.receiver_id = #{self.id} AND scraps.scrap_id IS NULL UNION SELECT id, updated_at, '#{ActionTracker::Record.to_s}' AS klass FROM #{ActionTracker::Record.table_name} WHERE action_tracker.target_id = #{self.id} UNION SELECT at.id, at.updated_at, '#{ActionTracker::Record.to_s}' AS klass FROM #{ActionTracker::Record.table_name} at INNER JOIN articles a ON at.target_id = a.id WHERE a.profile_id = #{self.id} AND at.target_type = 'Article' ORDER BY updated_at DESC") | |
91 | + Scrap.find_by_sql("SELECT id, updated_at, '#{Scrap.to_s}' AS klass FROM #{Scrap.table_name} WHERE scraps.receiver_id = #{self.id} AND scraps.scrap_id IS NULL UNION SELECT id, updated_at, '#{ActionTracker::Record.to_s}' AS klass FROM #{ActionTracker::Record.table_name} WHERE action_tracker.target_id = #{self.id} and action_tracker.verb != 'join_community' and action_tracker.verb != 'leave_scrap' UNION SELECT at.id, at.updated_at, '#{ActionTracker::Record.to_s}' AS klass FROM #{ActionTracker::Record.table_name} at INNER JOIN articles a ON at.target_id = a.id WHERE a.profile_id = #{self.id} AND at.target_type = 'Article' ORDER BY updated_at DESC") | |
92 | 92 | end |
93 | 93 | |
94 | 94 | end | ... | ... |
app/models/person.rb
... | ... | @@ -443,7 +443,7 @@ class Person < Profile |
443 | 443 | end |
444 | 444 | |
445 | 445 | def activities |
446 | - Scrap.find_by_sql("SELECT id, updated_at, '#{Scrap.to_s}' AS klass FROM #{Scrap.table_name} WHERE scraps.receiver_id = #{self.id} AND scraps.scrap_id IS NULL UNION SELECT id, updated_at, '#{ActionTracker::Record.to_s}' AS klass FROM #{ActionTracker::Record.table_name} WHERE action_tracker.user_id = #{self.id} ORDER BY updated_at DESC") | |
446 | + Scrap.find_by_sql("SELECT id, updated_at, '#{Scrap.to_s}' AS klass FROM #{Scrap.table_name} WHERE scraps.receiver_id = #{self.id} AND scraps.scrap_id IS NULL UNION SELECT id, updated_at, '#{ActionTracker::Record.to_s}' AS klass FROM #{ActionTracker::Record.table_name} WHERE action_tracker.user_id = #{self.id} and action_tracker.verb != 'leave_scrap_to_self' and action_tracker.verb != 'add_member_in_community' ORDER BY updated_at DESC") | |
447 | 447 | end |
448 | 448 | |
449 | 449 | protected | ... | ... |
test/functional/profile_controller_test.rb
... | ... | @@ -1139,8 +1139,10 @@ class ProfileControllerTest < ActionController::TestCase |
1139 | 1139 | |
1140 | 1140 | should "view more activities paginated" do |
1141 | 1141 | login_as(profile.identifier) |
1142 | - 40.times{ fast_create(ActionTracker::Record, :user_id => profile.id)} | |
1142 | + article = TinyMceArticle.create!(:profile => profile, :name => 'An Article about Free Software') | |
1143 | + 40.times{ ActionTracker::Record.create!(:user_id => profile.id, :user_type => 'Profile', :verb => 'create_article', :target_id => article.id, :target_type => 'Article', :params => {'name' => article.name, 'url' => article.url, 'lead' => article.lead, 'first_image' => article.first_image})} | |
1143 | 1144 | assert_equal 40, profile.tracked_actions.count |
1145 | + assert_equal 40, profile.activities.count | |
1144 | 1146 | get :view_more_activities, :profile => profile.identifier, :page => 2 |
1145 | 1147 | assert_response :success |
1146 | 1148 | assert_template '_profile_activities_list' | ... | ... |