<commit_before>module Refinery
  module Rates
    class RateTable < Refinery::Core::BaseModel
      extend FriendlyId
      self.table_name = 'refinery_rate_tables'

      attr_accessible :category, :title, :content, :position

      friendly_id :title, :use => [:slugged]
      acts_as_indexed :fields => [:title]

      validates :title, :presence => true, :uniqueness => true, :length => {:maximum => 255}
      validates :category, :length => {:maximum => 255, allow_blank: true}

      after_save :invalidate_cache, :if => lambda { changed? }
      after_save :update_effective_date, :if => lambda { changed? }

      def self.ordered
        order('category ASC, title ASC')
      end

      def inline_replacement_tag
        "{{rate_table #{to_param.to_s.underscore}}}" if persisted?
      end

      CATEGORIES = ['Checking', 'Savings', 'Dividend Rates', 'Loan Rates', 'Mortgage Rates']

      def category_options
        CATEGORIES
      end

      def invalidate_cache
        Rails.cache.delete([self.class, to_param])
      end

      def self.find_with_cache(url)
        Rails.cache.fetch([::Refinery::Rates::RateTable, url]) {<commit_msg>separate personal and business checking and savings<commit_after>module Refinery
  module Rates
    class RateTable < Refinery::Core::BaseModel
      extend FriendlyId
      self.table_name = 'refinery_rate_tables'

      attr_accessible :category, :title, :content, :position

      friendly_id :title, :use => [:slugged]
      acts_as_indexed :fields => [:title]

      validates :title, :presence => true, :uniqueness => true, :length => {:maximum => 255}
      validates :category, :length => {:maximum => 255, allow_blank: true}

      after_save :invalidate_cache, :if => lambda { changed? }
      after_save :update_effective_date, :if => lambda { changed? }

      def self.ordered
        order('category ASC, title ASC')
      end

      def inline_replacement_tag
        "{{rate_table #{to_param.to_s.underscore}}}" if persisted?
      end

      CATEGORIES = ['Personal Checking', 'Personal Savings', 'Business Checking', 'Business Savings', 'Dividend Rates', 'Loan Rates', 'Mortgage Rates']

      def category_options
        CATEGORIES
      end

      def invalidate_cache
        Rails.cache.delete([self.class, to_param])
      end

      def self.find_with_cache(url)
        Rails.cache.fetch([::Refinery::Rates::RateTable, url]) {
{'fraction_non_alphanumeric': 0.11798919817199834, 'fraction_numerical': 0.004985459077690071, 'mean_word_length': 3.1733102253032928, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '3418413', 'n_tokens_mistral': 783, 'n_tokens_neox': 719, 'n_words': 182}