Add by_latest_used scope, move admin area recent IPs to partial (#29497)

This commit is contained in:
Matt Jankowski 2024-04-02 09:51:34 -04:00 committed by GitHub
parent c70c39cad0
commit f56309f5f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 7 deletions

View File

@ -15,4 +15,6 @@ class UserIp < ApplicationRecord
self.primary_key = :user_id
belongs_to :user
scope :by_latest_used, -> { order(used_at: :desc) }
end

View File

@ -62,13 +62,7 @@
%td
%time.formatted{ datetime: account.created_at.iso8601, title: l(account.created_at) }= l account.created_at
%td
- recent_ips = account.user.ips.order(used_at: :desc).to_a
- recent_ips.each_with_index do |recent_ip, i|
%tr
- if i.zero?
%th{ rowspan: recent_ips.size }= t('admin.accounts.most_recent_ip')
%td= recent_ip.ip
%td= table_link_to 'search', t('admin.accounts.search_same_ip'), admin_accounts_path(ip: recent_ip.ip)
= render partial: 'admin/accounts/user_ip', collection: account.user.ips.by_latest_used
%tr
%th= t('admin.accounts.most_recent_activity')
%td

View File

@ -0,0 +1,5 @@
%tr
- if user_ip_iteration.first?
%th{ rowspan: user_ip_iteration.size }= t('admin.accounts.most_recent_ip')
%td= user_ip.ip
%td= table_link_to 'search', t('admin.accounts.search_same_ip'), admin_accounts_path(ip: user_ip.ip)