修改关注的排序

This commit is contained in:
sylor_huang@126.com 2020-06-08 09:55:54 +08:00
parent 28a839445f
commit c85dc3b57d
2 changed files with 5 additions and 5 deletions

View File

@ -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

View File

@ -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