<commit_before>module QuickJumpTargetsHelper
  def default_quickjump_targets
    targets = find_last_active_contents(:limit => 8, :type => Page).map(&:holder).compact.uniq
    quick_jumpify(targets)
  end

  def default_quickjump_projects(_limit = 20)
    targets = current_domain.projects.where(:active => true).limit(_limit).order("UPPER(title) ASC")
    quick_jumpify(targets)
  end

  def default_quickjump_pages(_limit = 20)
    targets = current_domain.pages.where("context_id IS NULL").limit(_limit).order("UPPER(title) ASC")
    quick_jumpify(targets)
  end

  def quick_jumpify(targets)
    targets.map do |record|
      url = url_for(record)
      record.attributes.merge(:type => record.class.to_s, :title => record.title, :url => url)
    end
  end

  # TODO: this solution seems terrible
  def find_last_active_contents(options = {})
    limit = options.fetch(:limit, 8)
    types = [options.fetch(:type)].flatten.compact.map(&:to_s)
    chain = Activity.accessible_by(current_ability).where(:user_id => current_user.id)
    chain = chain.where("verb <> 'read'").order("created_at DESC")
    offset = 0
    contents = []
    while contents.length < limit && offset < chain.count do
      activity = chain.offset(offset).first
      content = activity.try(:content).presence
      if content.present? && !contents.include?(content)
        if !types.present? || types.include?(content.holder_type)
          contents << activity.content
        end
      end
      offset += 1
    end
    contents
  end
end<commit_msg>Simplify default targets in QuickJumpHelper<commit_after>module QuickJumpTargetsHelper
  def default_quickjump_targets
    if current_project
      quick_jumpify(current_project.pages)
    else
      default_quickjump_pages(8)
    end
  end

  def default_quickjump_projects(_limit = 20)
    targets = current_domain.projects.where(:active => true).limit(_limit).order("UPPER(title) ASC")
    quick_jumpify(targets)
  end

  def default_quickjump_pages(_limit = 20)
    targets = current_domain.pages.where("context_id IS NULL").limit(_limit).order("UPPER(title) ASC")
    quick_jumpify(targets)
  end

  def quick_jumpify(targets)
    targets.map do |record|
      url = url_for(record)
      record.attributes.merge(:type => record.class.to_s, :title => record.title, :url => url)
    end
  end

end
{'fraction_non_alphanumeric': 0.11578044596912522, 'fraction_numerical': 0.005574614065180103, 'mean_word_length': 3.8604166666666666, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2352640', 'n_tokens_mistral': 765, 'n_tokens_neox': 717, 'n_words': 142}