From c85dc3b57d49ffa07d34cf45782cbcb85cef0639 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Mon, 8 Jun 2020 09:55:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=B3=E6=B3=A8=E7=9A=84?= =?UTF-8?q?=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 6 +++--- app/controllers/users_controller.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index a70a380da..050ae5513 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -83,19 +83,19 @@ class ProjectsController < ApplicationController end def watch_users - watchers = @project.watchers.includes(:user).order("watchers.created_at asc").distinct + watchers = @project.watchers.includes(:user).order("watchers.created_at desc").distinct @watchers_count = watchers.size @watchers = paginate(watchers) end def praise_users - praises = @project.praise_treads.includes(:user).order("praise_treads.created_at asc").distinct + praises = @project.praise_treads.includes(:user).order("praise_treads.created_at desc").distinct @praises_count = praises.size @praises = paginate(praises) end def fork_users - fork_users = @project.fork_users.includes(:user, :project).order("fork_users.created_at asc").distinct + fork_users = @project.fork_users.includes(:user, :project).order("fork_users.created_at desc").distinct @forks_count = fork_users.size @fork_users = paginate(fork_users) end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index b957a98d4..270680a97 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -23,7 +23,7 @@ class UsersController < ApplicationController end def watch_users - watchers = Watcher.watching_users(@user.id).includes(:user).order("watchers.created_at asc") + watchers = Watcher.watching_users(@user.id).includes(:user).order("watchers.created_at desc") if params[:search].present? search_user_ids = User.where(id: watchers.pluck(:watchable_id)).like(params[:search]).pluck(:id) watchers = watchers.where(watchable_id: search_user_ids) @@ -33,7 +33,7 @@ class UsersController < ApplicationController end def fan_users - watchers = @user.watchers.includes(:user).order("watchers.created_at asc") + watchers = @user.watchers.includes(:user).order("watchers.created_at desc") watchers = watchers.joins(:user).where("LOWER(concat(users.lastname, users.firstname, users.login)) LIKE ?", "%#{params[:search].split(" ").join('|')}%") if params[:search].present? @watchers_count = watchers.size