<commit_before>module Renalware
  module Letters
    class LetterQuery
      def initialize(q: nil)
        @q = q || {}
        @q[:s] ||= ["patient_family_name, patient_given_name"]
      end

      def call
        search.result
      end

      def search
        @search ||= QueryableLetter.search(@q)
      end

      class QueryableLetter < ActiveType::Record[Letter]
        def self.finder_needs_type_condition?; false; end

        scope :state_eq, -> (state = :draft) { where(type: Letter.state_class_name(state)) }

        private_class_method :ransackable_scopes

        def self.ransackable_scopes(_auth_object = nil)
          %i(state_eq)
        end
      end
    end
  end
end<commit_msg>Sort by issued_on date instead of name<commit_after>module Renalware
  module Letters
    class LetterQuery
      def initialize(q: nil)
        @q = q || {}
        @q[:s] ||= ["issued_on desc"]
      end

      def call
        search.result
      end

      def search
        @search ||= QueryableLetter.search(@q)
      end

      class QueryableLetter < ActiveType::Record[Letter]
        def self.finder_needs_type_condition?; false; end

        scope :state_eq, -> (state = :draft) { where(type: Letter.state_class_name(state)) }

        private_class_method :ransackable_scopes

        def self.ransackable_scopes(_auth_object = nil)
          %i(state_eq)
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.0925141242937853, 'fraction_numerical': 0.0, 'mean_word_length': 2.2877030162412995, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7579291', 'n_tokens_mistral': 454, 'n_tokens_neox': 427, 'n_words': 101}