Add user page to admin panel, improve other admin pages #88

Merged
raucao merged 15 commits from feature/admin_user_details into master 2023-02-26 14:16:41 +00:00
3 changed files with 16 additions and 1 deletions
Showing only changes of commit ffed398024 - Show all commits

View File

@ -1,4 +1,5 @@
class Admin::UsersController < Admin::BaseController
before_action :set_user, only: [:show]
before_action :set_current_section
def index
@ -12,8 +13,16 @@ class Admin::UsersController < Admin::BaseController
}
Review

Isn't this creating a new DB COUNT query? Since the @users are already there, wouldn't a @users.pending.size be more performant?

Isn't this creating a new DB `COUNT` query? Since the `@users` are already there, wouldn't a `@users.pending.size` be more performant?
Review

@users is not filtered by pending at that point, so .pending would actually create a query that selects all fields from the table using that filter, and then .size would convert the results into an array and count the contained items I believe. So .count should be more performant if that is correct.

`@users` is not filtered by pending at that point, so `.pending` would actually create a query that selects all fields from the table using that filter, and then `.size` would convert the results into an array and count the contained items I believe. So `.count` should be more performant if that is correct.
end
def show
end
private
def set_user
address = params[:address].split("@")
@user = User.where(cn: address.first, ou: address.last).first
end
def set_current_section
@current_section = :users
end

View File

@ -0,0 +1,6 @@
<%= render HeaderComponent.new(title: "User: #{@user.address}") %>
<%= render MainSimpleComponent.new do %>
<section>
</section>
<% end %>

View File

@ -39,7 +39,7 @@ Rails.application.routes.draw do
namespace :admin do
root to: 'dashboard#index'
resources 'users', only: ['index']
resources 'users', param: 'address', only: ['index', 'show'], constraints: { address: /.*/ }
Review

What's the constraints for? Doesn't the regex basically allow anything?

What's the `constraints` for? Doesn't the regex basically allow anything?
Review

It's to prevent Rails from parsing out the part behind the dot character as a format type. It would otherwise regard e.g. the "org" in "user@kosmos.org" as format "org".

It's to prevent Rails from parsing out the part behind the dot character as a format type. It would otherwise regard e.g. the "org" in "user@kosmos.org" as format "org".
get 'invitations', to: 'invitations#index'
resources :donations
get 'lightning', to: 'lightning#index'