Sort on and index taggings, ftw
This commit is contained in:
parent
d0ce257107
commit
e98cc4b960
3 changed files with 12 additions and 3 deletions
|
|
@ -64,7 +64,7 @@ class TagsController < ApplicationController
|
||||||
|
|
||||||
max_time = params[:max_time] ? Time.at(params[:max_time].to_i) : Time.now
|
max_time = params[:max_time] ? Time.at(params[:max_time].to_i) : Time.now
|
||||||
@posts = @posts.where(StatusMessage.arel_table[:created_at].lt(max_time))
|
@posts = @posts.where(StatusMessage.arel_table[:created_at].lt(max_time))
|
||||||
@posts = @posts.includes({:comments => {:author => :profile}}, :photos).order('posts.created_at DESC').limit(15)
|
@posts = @posts.includes({:comments => {:author => :profile}}, :photos).order('taggings.created_at DESC').limit(15)
|
||||||
else
|
else
|
||||||
@posts = []
|
@posts = []
|
||||||
end
|
end
|
||||||
|
|
|
||||||
8
db/migrate/20110707221112_index_taggings_created_at.rb
Normal file
8
db/migrate/20110707221112_index_taggings_created_at.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
class IndexTaggingsCreatedAt < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_index :taggings, :created_at
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20110705003445) do
|
ActiveRecord::Schema.define(:version => 20110707221112) do
|
||||||
|
|
||||||
create_table "aspect_memberships", :force => true do |t|
|
create_table "aspect_memberships", :force => true do |t|
|
||||||
t.integer "aspect_id", :null => false
|
t.integer "aspect_id", :null => false
|
||||||
|
|
@ -343,6 +343,7 @@ ActiveRecord::Schema.define(:version => 20110705003445) do
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_index "taggings", ["created_at"], :name => "index_taggings_on_created_at"
|
||||||
add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
|
add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
|
||||||
add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context"
|
add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context"
|
||||||
add_index "taggings", ["taggable_id", "taggable_type", "tag_id"], :name => "index_taggings_uniquely", :unique => true
|
add_index "taggings", ["taggable_id", "taggable_type", "tag_id"], :name => "index_taggings_uniquely", :unique => true
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue