Added/Updated admin dashboard tables
• Added: - New Account filtering - PreviewCard viewing/sorting/filtering deleting (todo) - DeletePreviewCardWorker, Service - Status viewing/sorting/filtering deleting - ChatMessage viewing/sorting/filtering deleting (todo) - Account > Follows view • Updated: - LinkBlock to sort alphabetically - Groups to be under "Moderation" instead of "Admin" in navigation.rb - Status in admin to have group name/link - Reports reset button - Group filtering/sorting - LinkBlock filtering/sorting - Account now has bio and few more data points in dashboard
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class StatusFilter
|
||||
attr_reader :status, :account
|
||||
attr_reader :status, :account, :params
|
||||
|
||||
def initialize(status, account, preloaded_relations = {})
|
||||
def initialize(status, account, preloaded_relations = {}, params)
|
||||
@status = status
|
||||
@account = account
|
||||
@preloaded_relations = preloaded_relations
|
||||
@params = params
|
||||
end
|
||||
|
||||
def filtered?
|
||||
@@ -14,6 +15,35 @@ class StatusFilter
|
||||
blocked_by_policy? || (account_present? && filtered_status?) || silenced_account?
|
||||
end
|
||||
|
||||
def results
|
||||
scope = Status
|
||||
params.each do |key, value|
|
||||
scope = scope.merge scope_for(key, value) if !value.nil? && !value.empty?
|
||||
end
|
||||
scope
|
||||
end
|
||||
|
||||
def scope_for(key, value)
|
||||
case key.to_sym
|
||||
when :text
|
||||
Status.where("LOWER(text) LIKE LOWER(?)", "%#{value}%")
|
||||
when :id
|
||||
Status.where(id: value)
|
||||
when :account_id
|
||||
Status.where(account_id: value)
|
||||
when :group_id
|
||||
Status.where(group_id: value)
|
||||
when :preview_card_id
|
||||
Status.joins(:preview_cards).where("preview_cards.id = #{value.to_i}")
|
||||
when :created_at_lte
|
||||
Status.where("created_at <= ?", value)
|
||||
when :created_at_gte
|
||||
Status.where("created_at >= ?", value)
|
||||
else
|
||||
raise "Unknown filter: #{key}"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def account_present?
|
||||
|
||||
Reference in New Issue
Block a user