Skip to content

Commit

Permalink
Fix relationships page not showing results in admin UI (mastodon#12934)
Browse files Browse the repository at this point in the history
Follow-up to mastodon#12927
  • Loading branch information
Gargron authored Jan 23, 2020
1 parent dee853f commit ce1dee8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/relationships_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def set_account
end

def filter_params
params.slice(RelationshipFilter::KEYS).permit(RelationshipFilter::KEYS)
params.slice(*RelationshipFilter::KEYS).permit(*RelationshipFilter::KEYS)
end
end
end
20 changes: 10 additions & 10 deletions app/models/relationship_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ def initialize(account, params)
end

def results
scope = scope_for('relationship', params['relationship'])
scope = scope_for('relationship', params['relationship'].to_s.strip)

params.each do |key, value|
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

scope
Expand All @@ -39,7 +39,7 @@ def set_defaults!
end

def scope_for(key, value)
case key.to_s
case key
when 'relationship'
relationship_scope(value)
when 'by_domain'
Expand All @@ -58,7 +58,7 @@ def scope_for(key, value)
end

def relationship_scope(value)
case value.to_s
case value
when 'following'
account.following.eager_load(:account_stat).reorder(nil)
when 'followed_by'
Expand All @@ -73,11 +73,11 @@ def relationship_scope(value)
end

def by_domain_scope(value)
Account.where(domain: value.to_s)
Account.where(domain: value)
end

def location_scope(value)
case value.to_s
case value
when 'local'
Account.local
when 'remote'
Expand All @@ -88,7 +88,7 @@ def location_scope(value)
end

def status_scope(value)
case value.to_s
case value
when 'moved'
Account.where.not(moved_to_account_id: nil)
when 'primary'
Expand All @@ -99,18 +99,18 @@ def status_scope(value)
end

def order_scope(value)
case value.to_s
case value
when 'active'
Account.by_recent_status
when 'recent'
Follow.recent
params[:relationship] == 'invited' ? Account.recent : Follow.recent
else
raise "Unknown order: #{value}"
end
end

def activity_scope(value)
case value.to_s
case value
when 'dormant'
AccountStat.where(last_status_at: nil).or(AccountStat.where(AccountStat.arel_table[:last_status_at].lt(1.month.ago)))
else
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/accounts/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
.dashboard__counters__num= number_to_human_size @account.media_attachments.sum('file_file_size')
.dashboard__counters__label= t 'admin.accounts.media_attachments'
%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__label= t 'admin.accounts.followers'
%div
Expand Down

0 comments on commit ce1dee8

Please sign in to comment.