<commit_before>class DashboardsController < ApplicationController
  def show
    @user = current_user
    @groups = @user.groups

    @relevant_issues = IssueDecorator.decorate(current_user.issues_near_locations.order("updated_at DESC"))

    @subscribed_threads = ThreadListDecorator.decorate(current_user.subscribed_threads.order_by_latest_message.limit(8))

    group_threads = ThreadList.recent_from_groups(current_user.groups, 8)
    @group_threads = ThreadListDecorator.decorate(group_threads)

    deadline_threads = ThreadList.with_upcoming_deadlines(current_user, 8)
    @deadline_threads = ThreadListDecorator.decorate(deadline_threads)

    @prioritised_threads = ThreadListDecorator.decorate(current_user.prioritised_threads.order("priority desc").order_by_latest_message.limit(20))
  end

  def search
    # Ideally, this would be delegated to the different controllers.

    @query = params[:query]

    # Threads, with permission check
    unfiltered_results = MessageThread.find_with_index(@query)
    results = unfiltered_results.select{ |t| permitted_to?(:show, t) }
    @threads = ThreadListDecorator.decorate(results)

    # Issues
    issues = Issue.find_with_index(@query)
    @issues = IssueDecorator.decorate(issues)

    # Library Items
    library_items = Library::Item.find_with_index(@query)
    @library_items = Library::ItemDecorator.decorate(library_items)

    # Users? Groups?
  end
end
<commit_msg>Preload various aspects of the dashboard.<commit_after>class DashboardsController < ApplicationController
  def show
    @user = current_user
    @groups = @user.groups

    @relevant_issues = IssueDecorator.decorate(current_user.issues_near_locations.order("updated_at DESC").includes(:created_by, :tags))

    subscribed_threads = current_user.subscribed_threads.order_by_latest_message.limit(8).includes(:issue, {latest_message: [:component, :created_by]})
    @subscribed_threads = ThreadListDecorator.decorate(subscribed_threads)

    group_threads = ThreadList.recent_from_groups(current_user.groups, 8).includes({issue: :tags}, :group)
    @group_threads = ThreadListDecorator.decorate(group_threads)

    deadline_threads = ThreadList.with_upcoming_deadlines(current_user, 8).includes(:issue)
    @deadline_threads = ThreadListDecorator.decorate(deadline_threads)

    prioritised_threads = current_user.prioritised_threads.order("priority desc").order_by_latest_message.limit(20).includes(:issue, {latest_message: [:component, :created_by]})
    @prioritised_threads = ThreadListDecorator.decorate(prioritised_threads)
  end

  def search
    # Ideally, this would be delegated to the different controllers.

    @query = params[:query]

    # Threads, with permission check
    unfiltered_results = MessageThread.find_with_index(@query)
    results = unfiltered_results.select{ |t| permitted_to?(:show, t) }
    @threads = ThreadListDecorator.decorate(results)

    # Issues
    issues = Issue.find_with_index(@query)
    @issues = IssueDecorator.decorate(issues)

    # Library Items
    library_items = Library::Item.find_with_index(@query)
    @library_items = Library::ItemDecorator.decorate(library_items)

    # Users? Groups?
  end
end

{'fraction_non_alphanumeric': 0.09481946624803768, 'fraction_numerical': 0.0031397174254317113, 'mean_word_length': 5.542094455852156, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6425692', 'n_tokens_mistral': 1008, 'n_tokens_neox': 951, 'n_words': 156}