<commit_before>class InquirySweeper < ActionController::Caching::Sweeper
  observe :spud_inquiry_form,:spud_inquiry_form_field

  def before_save(record)
    if record.is_a?(SpudInquiryForm)
      @old_name = record.name_was
    else
      @old_name = nil
    end
  end

  def after_save(record)
    if record.is_a?(SpudInquiryFormField)
      reset_cms_pages(record.spud_inquiry_form)
    else
      reset_cms_pages(record)
    end
  end
  def after_destroy(record)
    if record.is_a?(SpudInquiryFormField)
      reset_cms_pages(record.spud_inquiry_form)
    else
      reset_cms_pages(record)
    end
  end
private
  def reset_cms_pages(record)
    if defined? Spud::Cms::Engine #Is CMS Being Used?
      values = [record.name]
      values << @old_name if !@old_name.blank?
      SpudPageLiquidTag.where(:tag_name => "inquiry",:value => values).includes(:attachment).each do |tag|
        partial = tag.attachment
        partial.postprocess_content
        partial.save
        page = partial.try(:spud_page)
        if page.blank? == false
          page.updated_at = Time.now.utc
          page.save
        end
      end

    end
  end



end<commit_msg>fixing issue with using snippets and inquiry forms<commit_after>class InquirySweeper < ActionController::Caching::Sweeper
  observe :spud_inquiry_form,:spud_inquiry_form_field

  def before_save(record)
    if record.is_a?(SpudInquiryForm)
      @old_name = record.name_was
    else
      @old_name = nil
    end
  end

  def after_save(record)
    if record.is_a?(SpudInquiryFormField)
      reset_cms_pages(record.spud_inquiry_form)
    else
      reset_cms_pages(record)
    end
  end
  def after_destroy(record)
    if record.is_a?(SpudInquiryFormField)
      reset_cms_pages(record.spud_inquiry_form)
    else
      reset_cms_pages(record)
    end
  end
private
  def reset_cms_pages(record)
    if defined? Spud::Cms::Engine #Is CMS Being Used?
      values = [record.name]
      values << @old_name if !@old_name.blank?
      SpudPageLiquidTag.where(:tag_name => "inquiry",:value => values).includes(:attachment).each do |tag|
        partial = tag.attachment
        partial.postprocess_content
        partial.save
        page = nil
        if(partial.attributes.has_key? 'spud_page')
          page = partial.try(:spud_page)
        end
        if page.blank? == false
          page.updated_at = Time.now.utc
          page.save
        end
      end

    end
  end



end
{'fraction_non_alphanumeric': 0.08585445625511039, 'fraction_numerical': 0.0, 'mean_word_length': 2.835423197492163, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '6118884', 'n_tokens_mistral': 840, 'n_tokens_neox': 823, 'n_words': 155}