[Admin] dumb hacky test stuff

This commit is contained in:
Kira 2020-04-30 16:34:31 -07:00
parent 587cce61d8
commit 61bc341df7
3 changed files with 44 additions and 1 deletions

View File

@ -1,6 +1,18 @@
module Admin
class UsersController < ApplicationController
before_action :moderator_only
respond_to :html, :json
def alt_list
offset = params[:page].to_i || 0
offset *= 100
@alts = ::User.connection.select_all("
SELECT u1.id as u1id, u1.name as u1name, u2.id as u2id, u2.name as u2name, u1.last_ip_addr, u1.email as u1email, u2.email as u2email, u2.last_logged_in_at
FROM (SELECT * FROM users ORDER BY id DESC LIMIT 100 OFFSET #{offset}) u1
INNER JOIN users u2 ON u1.last_ip_addr = u2.last_ip_addr AND u1.id != u2.id AND u2.last_logged_in_at > now() - interval '3 months'
ORDER BY u1.id DESC, u2.last_logged_in_at DESC;")
respond_with(@alts)
end
def edit
@user = User.find(params[:id])

View File

@ -0,0 +1,28 @@
<table class="table">
<thead>
<tr>
<th>ID #1</th>
<th>Name #1</th>
<th>Email #1</th>
<th>IP</th>
<th>ID #2</th>
<th>Name #2</th>
<th>Email #2</th>
<th>Last Login #2</th>
</tr>
</thead>
<tbody>
<% @alts.each do |alt| %>
<tr>
<td><%= link_to alt['u1id'], user_path(id: alt['u1id']) %></td>
<td><%= link_to alt['u1name'], user_path(id: alt['u1id']) %></td>
<td><%= alt['u1email'] %></td>
<td><%= link_to_ip alt['last_ip_addr'] %></td>
<td><%= link_to alt['u2id'], user_path(id: alt['u2id']) %></td>
<td><%= link_to alt['u2name'], user_path(id: alt['u2id']) %></td>
<td><%= alt['u2email'] %></td>
<td><%= alt['last_logged_in_at'] %></td>
</tr>
<% end %>
</tbody>
</table>

View File

@ -7,13 +7,16 @@ Rails.application.routes.draw do
mount Sidekiq::Web => '/sidekiq', constraints: AdminRouteConstraint.new
namespace :admin do
resources :users, :only => [:edit, :update, :edit_blacklist, :update_blacklist] do
resources :users, :only => [:edit, :update, :edit_blacklist, :update_blacklist, :alt_list] do
member do
get :edit_blacklist
post :update_blacklist
get :request_password_reset
post :password_reset
end
collection do
get :alt_list
end
end
resource :alias_and_implication_import, :only => [:new, :create]
resource :dashboard, :only => [:show]