summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjomo <git@jomo.tv>2017-07-07 01:57:30 +0200
committerjomo <git@jomo.tv>2017-07-07 01:57:30 +0200
commit72a6dcc54ad64d1168fbab7bb3d9cd663cc3b012 (patch)
tree4453125f7aa9a9f6cbd62645da4d66877f7abea9
parent4e1b6b430b58c1f6191af89f55c5c498e7a65e6d (diff)
order by id instead of created_at
id is indexed while created_at is not
-rw-r--r--app/controllers/blogposts_controller.rb2
-rw-r--r--app/controllers/forumthreads_controller.rb4
-rw-r--r--app/models/forumthread.rb2
-rw-r--r--app/views/forums/index.html.erb2
4 files changed, 5 insertions, 5 deletions
diff --git a/app/controllers/blogposts_controller.rb b/app/controllers/blogposts_controller.rb
index 7a9851d..1ff310d 100644
--- a/app/controllers/blogposts_controller.rb
+++ b/app/controllers/blogposts_controller.rb
@@ -4,7 +4,7 @@ class BlogpostsController < ApplicationController
before_filter :auth, except: [:index, :show]
def index
- @posts = Blogpost.order("created_at desc").page(params[:page]).per(10)
+ @posts = Blogpost.order(id: :desc).page(params[:page]).per(10)
end
def show
diff --git a/app/controllers/forumthreads_controller.rb b/app/controllers/forumthreads_controller.rb
index a5e3d6d..d40ce58 100644
--- a/app/controllers/forumthreads_controller.rb
+++ b/app/controllers/forumthreads_controller.rb
@@ -12,9 +12,9 @@ class ForumthreadsController < ApplicationController
end
def show
if params[:reverse] == "true"
- @replies = @thread.replies.order(created_at: :desc).page(params[:page])
+ @replies = @thread.replies.order(id: :desc).page(params[:page])
else
- @replies = @thread.replies.order(:created_at).page(params[:page])
+ @replies = @thread.replies.order(:id).page(params[:page])
end
end
diff --git a/app/models/forumthread.rb b/app/models/forumthread.rb
index f8efe97..fd8d3c1 100644
--- a/app/models/forumthread.rb
+++ b/app/models/forumthread.rb
@@ -106,7 +106,7 @@ class Forumthread < ActiveRecord::Base
if order_phrase.present?
threads = threads.order("GREATEST(relevance, reply_rel) DESC")
else
- threads = threads.order("sticky desc", "threadreplies.created_at DESC", "forumthreads.created_at DESC")
+ threads = threads.order("sticky DESC", "threadreplies.id DESC", "forumthreads.id DESC")
end
threads
end
diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb
index 532484b..a30730a 100644
--- a/app/views/forums/index.html.erb
+++ b/app/views/forums/index.html.erb
@@ -18,7 +18,7 @@
<%= link_to f.name, f, id: "forum-#{f.id}"%>
<div class="item-info">
<% if last_thread = f.threads.last %>
- <% last_reply = Threadreply.where(forumthread: f.threads).order(:created_at).last %>
+ <% last_reply = Threadreply.where(forumthread: f.threads).order(:id).last %>
<% if last_reply && last_reply.created_at > last_thread.created_at %>
<% if last_reply.thread.can_read?(current_user) %>
<%= last_reply.author.name %>