diff --git a/app/models/post.rb b/app/models/post.rb index 5798e067e..4743ff48e 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -46,6 +46,10 @@ class Post < ActiveRecord::Base end end + def reshare_count + @reshare_count ||= Post.where(:root_guid => self.guid).count + end + def diaspora_handle= nd self.author = Person.where(:diaspora_handle => nd).first write_attribute(:diaspora_handle, nd) diff --git a/app/views/reshares/_reshare.haml b/app/views/reshares/_reshare.haml index 224829354..4ccee89f1 100644 --- a/app/views/reshares/_reshare.haml +++ b/app/views/reshares/_reshare.haml @@ -16,7 +16,7 @@ %span.timeago = link_to(how_long_ago(post), post_path(post)) – - = t("reshares.reshare.reshare", :count => post.reshares.size) + = t("reshares.reshare.reshare", :count => post.reshare_count) - if post.activity_streams? = link_to image_tag(post.image_url, 'data-small-photo' => post.image_url, 'data-full-photo' => post.image_url, :class => 'stream-photo'), post.object_url, :class => "stream-photo-link" diff --git a/db/migrate/20110930182048_add_root_guid_index_to_posts.rb b/db/migrate/20110930182048_add_root_guid_index_to_posts.rb new file mode 100644 index 000000000..ce3e9bdf5 --- /dev/null +++ b/db/migrate/20110930182048_add_root_guid_index_to_posts.rb @@ -0,0 +1,9 @@ +class AddRootGuidIndexToPosts < ActiveRecord::Migration + def self.up + add_index :posts, :root_guid + end + + def self.down + remove_index :posts, :column => :root_guid + end +end diff --git a/db/schema.rb b/db/schema.rb index c7addc365..a68afbe09 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20110926120220) do +ActiveRecord::Schema.define(:version => 20110930182048) do create_table "aspect_memberships", :force => true do |t| t.integer "aspect_id", :null => false @@ -287,6 +287,7 @@ ActiveRecord::Schema.define(:version => 20110926120220) do add_index "posts", ["author_id"], :name => "index_posts_on_person_id" add_index "posts", ["guid"], :name => "index_posts_on_guid", :unique => true + add_index "posts", ["root_guid"], :name => "index_posts_on_root_guid" add_index "posts", ["status_message_guid", "pending"], :name => "index_posts_on_status_message_guid_and_pending" add_index "posts", ["status_message_guid"], :name => "index_posts_on_status_message_guid" add_index "posts", ["type", "pending", "id"], :name => "index_posts_on_type_and_pending_and_id"