Browse Source

Fix relationships page not showing results in admin UI (#12934)

Follow-up to #12927
closed-social-v3
Eugen Rochko 4 years ago
committed by GitHub
parent
commit
ce1dee85b5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 12 deletions
  1. +1
    -1
      app/controllers/admin/relationships_controller.rb
  2. +10
    -10
      app/models/relationship_filter.rb
  3. +1
    -1
      app/views/admin/accounts/show.html.haml

+ 1
- 1
app/controllers/admin/relationships_controller.rb View File

@ -19,7 +19,7 @@ module Admin
end end
def filter_params def filter_params
params.slice(RelationshipFilter::KEYS).permit(RelationshipFilter::KEYS)
params.slice(*RelationshipFilter::KEYS).permit(*RelationshipFilter::KEYS)
end end
end end
end end

+ 10
- 10
app/models/relationship_filter.rb View File

@ -20,12 +20,12 @@ class RelationshipFilter
end end
def results def results
scope = scope_for('relationship', params['relationship'])
scope = scope_for('relationship', params['relationship'].to_s.strip)
params.each do |key, value| params.each do |key, value|
next if key.to_s == 'page' next if key.to_s == 'page'
scope.merge!(scope_for(key, value)) if value.present?
scope.merge!(scope_for(key.to_s, value.to_s.strip)) if value.present?
end end
scope scope
@ -39,7 +39,7 @@ class RelationshipFilter
end end
def scope_for(key, value) def scope_for(key, value)
case key.to_s
case key
when 'relationship' when 'relationship'
relationship_scope(value) relationship_scope(value)
when 'by_domain' when 'by_domain'
@ -58,7 +58,7 @@ class RelationshipFilter
end end
def relationship_scope(value) def relationship_scope(value)
case value.to_s
case value
when 'following' when 'following'
account.following.eager_load(:account_stat).reorder(nil) account.following.eager_load(:account_stat).reorder(nil)
when 'followed_by' when 'followed_by'
@ -73,11 +73,11 @@ class RelationshipFilter
end end
def by_domain_scope(value) def by_domain_scope(value)
Account.where(domain: value.to_s)
Account.where(domain: value)
end end
def location_scope(value) def location_scope(value)
case value.to_s
case value
when 'local' when 'local'
Account.local Account.local
when 'remote' when 'remote'
@ -88,7 +88,7 @@ class RelationshipFilter
end end
def status_scope(value) def status_scope(value)
case value.to_s
case value
when 'moved' when 'moved'
Account.where.not(moved_to_account_id: nil) Account.where.not(moved_to_account_id: nil)
when 'primary' when 'primary'
@ -99,18 +99,18 @@ class RelationshipFilter
end end
def order_scope(value) def order_scope(value)
case value.to_s
case value
when 'active' when 'active'
Account.by_recent_status Account.by_recent_status
when 'recent' when 'recent'
Follow.recent
params[:relationship] == 'invited' ? Account.recent : Follow.recent
else else
raise "Unknown order: #{value}" raise "Unknown order: #{value}"
end end
end end
def activity_scope(value) def activity_scope(value)
case value.to_s
case value
when 'dormant' when 'dormant'
AccountStat.where(last_status_at: nil).or(AccountStat.where(AccountStat.arel_table[:last_status_at].lt(1.month.ago))) AccountStat.where(last_status_at: nil).or(AccountStat.where(AccountStat.arel_table[:last_status_at].lt(1.month.ago)))
else else

+ 1
- 1
app/views/admin/accounts/show.html.haml View File

@ -41,7 +41,7 @@
.dashboard__counters__num= number_to_human_size @account.media_attachments.sum('file_file_size') .dashboard__counters__num= number_to_human_size @account.media_attachments.sum('file_file_size')
.dashboard__counters__label= t 'admin.accounts.media_attachments' .dashboard__counters__label= t 'admin.accounts.media_attachments'
%div %div
= link_to admin_account_relationships_path(@account.id, location: 'local') do
= link_to admin_account_relationships_path(@account.id, location: 'local', relationship: 'followed_by') do
.dashboard__counters__num= number_with_delimiter @account.local_followers_count .dashboard__counters__num= number_with_delimiter @account.local_followers_count
.dashboard__counters__label= t 'admin.accounts.followers' .dashboard__counters__label= t 'admin.accounts.followers'
%div %div

Loading…
Cancel
Save