<commit_before>require 'spree_microcms/engine'

module SpreeMicrocms
  mattr_accessor :user_class
  mattr_accessor :base_controller

  class PageCache
    def self.pages
      Rails.cache.fetch("#{key_base}-pages", expires_in: 1.week) do
        ::SpreeMicrocms::Page.all.to_a
      end
    end

    def self.page_by_slug(slug)
      pages_by_slug = Rails.cache.fetch("#{key_base}-pages-by-slug", expires_in: 1.week) do
        _pages_by_slug = {}
        pages.each do |p|
          _pages_by_slug[p.slug] = p
        end
        _pages_by_slug
      end<commit_msg>rubocop: refactor *page_by_slug* method<commit_after>require 'spree_microcms/engine'

module SpreeMicrocms
  mattr_accessor :user_class
  mattr_accessor :base_controller

  class PageCache
    def self.pages
      Rails.cache.fetch("#{key_base}-pages", expires_in: 1.week) do
        ::SpreeMicrocms::Page.all.to_a
      end
    end

    def self.page_by_slug(slug)
      pages_by_slug = Rails.cache.fetch("#{key_base}-pages-by-slug", expires_in: 1.week) do |_key|
        pages.map { |p| [p.slug, p] }.to_h
      end
{'fraction_non_alphanumeric': 0.10977859778597786, 'fraction_numerical': 0.0036900369003690036, 'mean_word_length': 3.0636704119850187, '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': '1032599', 'n_tokens_mistral': 418, 'n_tokens_neox': 405, 'n_words': 70}