<commit_before>module HeapHop
  module Reports
    class GenerationObjectCount

      attr_reader :raw_results
      attr_reader :counts

      def initialize(results)
        @raw_results = results
        @counts = results.each_with_object({}) do |row, acc|
          acc[row["generation"]] = row["count"]
        end
      end

      def generation_count
        counts.size
      end

      def generation(g)
        counts[g]
      end

      def self.call(db)
        results = db.execute(<<-SQL)
          SELECT generation, COUNT(*) AS 'count'
          FROM 'heap_objects'
          GROUP BY 'generation'
          ORDER BY 'generation' DESC
        SQL
        new(results)
      end
    end
  end
end<commit_msg>definitely need ASC here<commit_after>module HeapHop
  module Reports
    class GenerationObjectCount

      attr_reader :raw_results
      attr_reader :counts

      def initialize(results)
        @raw_results = results
        @counts = results.each_with_object({}) do |row, acc|
          acc[row["generation"]] = row["count"]
        end
      end

      def generation_count
        counts.size
      end

      def generation(g)
        counts[g]
      end

      def self.call(db)
        results = db.execute(<<-SQL)
          SELECT generation, COUNT(*) AS 'count'
          FROM 'heap_objects'
          GROUP BY 'generation'
          ORDER BY 'generation' ASC
        SQL
        new(results)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.08104395604395605, 'fraction_numerical': 0.0, 'mean_word_length': 1.845703125, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1880135', 'n_tokens_mistral': 440, 'n_tokens_neox': 411, 'n_words': 112}