Skip to content

Commit

Permalink
Fix /admin/users page slow, and remove form-select. (#1443)
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee authored Oct 29, 2024
1 parent 848e68b commit e68e7ac
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 11 deletions.
2 changes: 0 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ [email protected]
# application server config
# number of processes for Puma & Nginx
workers=2
min_threads=8
max_threads=16

# [Sidekiq]
sidekiq_threads=20
Expand Down
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ gem "ruby-push-notifications"
gem "action-store"

gem "enumize"
gem "form-select"
gem "kaminari"

gem "exception-track"
Expand Down
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ GEM
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
ffi (1.17.0-x86_64-linux-musl)
form-select (0.3.2)
rails (>= 4.2)
fugit (1.11.1)
et-orbi (~> 1, >= 1.2.11)
raabro (~> 1.4)
Expand Down Expand Up @@ -587,7 +585,6 @@ DEPENDENCIES
exception-track
factory_bot_rails
faraday-rack
form-select
html-pipeline (~> 2.14)
html-pipeline-auto-correct
http_accept_language
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Admin
class UsersController < Admin::ApplicationController
def index
scope = User.all.includes(:profile)
scope = User.includes(:profile)
scope = scope.where(type: params[:type]) if params[:type].present?
scope = scope.where(state: params[:state]) if params[:state].present?
field = params[:field] || "login"
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/searchable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ def indexed_changed?
end

def reindex!
SearchDocument.index(self)
# SearchDocument.index(self)
end
end
4 changes: 3 additions & 1 deletion app/models/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class Node < ApplicationRecord
scope :hots, -> { order(topics_count: :desc) }
scope :sorted, -> { order(sort: :desc) }

form_select :name
def self.name_options
self.all.collect { |node| [node.name, node.id] }
end

def self.find_builtin_node(id, name)
node = find_by_id(id)
Expand Down
2 changes: 0 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ class User < ApplicationRecord
:location_id, :twitter, :team_users_count, :created_at, :updated_at)
}

form_select :state

# Override Devise database authentication
def self.find_for_database_authentication(warden_conditions)
conditions = warden_conditions.dup
Expand Down
4 changes: 4 additions & 0 deletions app/models/user/roles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ module Roles
included do
enum :state, { deleted: -1, member: 1, blocked: 2, vip: 3, hr: 4, maintainer: 90, admin: 99 }

def self.state_options
self.states.map { |key, value| [I18n.t("activerecord.enums.user.state.#{key}"), value] }
end

# user.admin?
define_method :admin? do
state.to_s == "admin" || Setting.admin_emails.include?(email)
Expand Down

0 comments on commit e68e7ac

Please sign in to comment.