<commit_before># frozen_string_literal: true

class Api::V1::BlocksController < ApiController
  before_action -> { doorkeeper_authorize! :follow }
  before_action :require_user!

  respond_to :json

  def index
    @accounts = Account.includes(:blocked_by)
                       .references(:blocked_by)
                       .merge(Block.where(account: current_account)
                                   .paginate_by_max_id(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:max_id], params[:since_id]))
                       .to_a

    next_path = api_v1_blocks_url(pagination_params(max_id: @accounts.last.blocked_bies.last.id))     if @accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
    prev_path = api_v1_blocks_url(pagination_params(since_id: @accounts.first.blocked_bies.first.id)) unless @accounts.empty?

    set_pagination_headers(next_path, prev_path)
  end

  private

  def pagination_params(core_params)
    params.permit(:limit).merge(core_params)
  end
end
<commit_msg>Fix block list 500 (#3174)<commit_after># frozen_string_literal: true

class Api::V1::BlocksController < ApiController
  before_action -> { doorkeeper_authorize! :follow }
  before_action :require_user!

  respond_to :json

  def index
    @accounts = Account.includes(:blocked_by)
                       .references(:blocked_by)
                       .merge(Block.where(account: current_account)
                                   .paginate_by_max_id(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:max_id], params[:since_id]))
                       .to_a

    next_path = api_v1_blocks_url(pagination_params(max_id: @accounts.last.blocked_by_ids.last))     if @accounts.size == limit_param(DEFAULT_ACCOUNTS_LIMIT)
    prev_path = api_v1_blocks_url(pagination_params(since_id: @accounts.first.blocked_by_ids.first)) unless @accounts.empty?

    set_pagination_headers(next_path, prev_path)
  end

  private

  def pagination_params(core_params)
    params.permit(:limit).merge(core_params)
  end
end

{'fraction_non_alphanumeric': 0.09401709401709402, 'fraction_numerical': 0.006535947712418301, 'mean_word_length': 3.451901565995526, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4031505', 'n_tokens_mistral': 662, 'n_tokens_neox': 636, 'n_words': 92}