Permalink
Browse files

Fixed loss of attribution of example authorship on profile page's recent

updates section.
  • Loading branch information...
1 parent dcff8cc commit 754dc87289e188e56074da324b5e1be6ca614e2a @zk committed Oct 24, 2010
Showing with 10 additions and 1 deletion.
  1. +10 −1 app/controllers/user_controller.rb
View
11 app/controllers/user_controller.rb
@@ -22,6 +22,15 @@ def profile
return
end
- @recent = (@user.comments + @user.examples + @user.see_alsos).sort{|a,b| b.updated_at <=> a.updated_at}
+ examples = @user.examples
+ examples_map = @user.examples.reduce({}) {|coll, e| coll.merge({e.function_id => e})}
+ Example.find_by_sql(["select * from example_versions where user_id = ?", @user.id]).each do |e|
+ if not examples_map[e.function_id]
+ examples << e
+ examples_map = examples_map.merge({e.function_id => e})
+ end
+ end
+
+ @recent = (@user.comments + examples + @user.see_alsos).uniq.sort{|a,b| b.updated_at <=> a.updated_at}
end
end

0 comments on commit 754dc87

Please sign in to comment.