<commit_before>if defined?(Comment)
  module Activities
    class CommentObserver < Activities::Logger

      observe :comment

      logs_activity do |log|
        log.edited :if => [:body_changed?, {:not => :new_record?}]
        log.approved :if => [:approved_changed?, :approved?]
        log.unapproved :if => [:approved_changed?, :unapproved?]
      end

      def collect_activity_attributes(record)
        attrs = record.send(:clone_attributes)
        attrs = attrs.slice 'commentable_id', 'body', 'author_name', 'author_email', 'author_url'
        type = record.commentable.has_attribute?('type') ? record.commentable['type'] : record.commentable_type
        attrs.update('commentable_type' => type, 'commentable_title' => record.commentable.title)
      end

      def initialize_activity(record)
        super.tap do |activity|
          activity.site = record.commentable.site
          activity.section = record.commentable.section
          activity.author = record.author
        end
      end
    end
  end
end<commit_msg>zeitwerk eager load gets mad if the file doesn't define the expected constant.<commit_after>if defined?(Comment)
  module Activities
    class CommentObserver < Activities::Logger

      observe :comment

      logs_activity do |log|
        log.edited :if => [:body_changed?, {:not => :new_record?}]
        log.approved :if => [:approved_changed?, :approved?]
        log.unapproved :if => [:approved_changed?, :unapproved?]
      end

      def collect_activity_attributes(record)
        attrs = record.send(:clone_attributes)
        attrs = attrs.slice 'commentable_id', 'body', 'author_name', 'author_email', 'author_url'
        type = record.commentable.has_attribute?('type') ? record.commentable['type'] : record.commentable_type
        attrs.update('commentable_type' => type, 'commentable_title' => record.commentable.title)
      end

      def initialize_activity(record)
        super.tap do |activity|
          activity.site = record.commentable.site
          activity.section = record.commentable.section
          activity.author = record.author
        end
      end
    end
  end
else # stub constant to make zeitwerk eagerload happy
  module Activities
    class CommentObserver; end
  end
end
{'fraction_non_alphanumeric': 0.10707964601769912, 'fraction_numerical': 0.0, 'mean_word_length': 3.103448275862069, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '3224733', 'n_tokens_mistral': 644, 'n_tokens_neox': 619, 'n_words': 149}