<commit_before>require_dependency "renalware/patients"

module Renalware
  module Patients
    class WorryQuery
      attr_reader :query_params

      def initialize(query_params)
        @query_params = query_params
        @query_params[:s] = "date_time DESC" if @query_params[:s].blank?
      end

      def call
        search
          .result
          .includes(patient: { current_modality: [:description] })
          .order(created_at: :asc)
          .page(query_params[:page])
          .per(query_params[:per_page])
      end

      def search
        @search ||= Worry.ransack(query_params)
      end
    end
  end
end
<commit_msg>Resolve Worryboard list N+1 issues<commit_after>require_dependency "renalware/patients"

module Renalware
  module Patients
    class WorryQuery
      attr_reader :query_params

      def initialize(query_params)
        @query_params = query_params
        @query_params[:s] = "date_time DESC" if @query_params[:s].blank?
      end

      def call
        search
          .result
          .includes(:created_by, patient: { current_modality: [:description] })
          .order(created_at: :asc)
          .page(query_params[:page])
          .per(query_params[:per_page])
      end

      def search
        @search ||= Worry.ransack(query_params)
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.09152798789712557, 'fraction_numerical': 0.0007564296520423601, 'mean_word_length': 2.375, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5315220', 'n_tokens_mistral': 411, 'n_tokens_neox': 397, 'n_words': 85}