<commit_before># frozen_string_literal: true

class ProjectPost < ActiveRecord::Base
  include I18n::Alchemy
  include Shared::CommonWrapper
  has_notifications

  belongs_to :project, inverse_of: :posts
  belongs_to :reward
  belongs_to :user
  delegate :email_comment_html, to: :decorator

  before_save do
    reference_user
  end
  after_save :index_on_common

  validates_presence_of :user_id, :project_id, :comment_html, :title

  before_validation :reference_user

  scope :ordered, ->() { order('created_at desc') }

  def reference_user
    self.user_id = project.try(:user_id)
  end

  def to_partial_path
    'projects/posts/project_post'
  end

  def decorator
    @decorator ||= ProjectPostDecorator.new(self)
  end

  def common_index
    id_hash = common_id.present? ? {id: common_id} : {}

    {
      external_id: id,
      project_id: project.common_id,
      reward_id: reward.common_id,
      current_ip: project.user.current_sign_in_ip,
      comment_html: comment_html,
      title: title,<commit_msg>fix docker config<commit_after># frozen_string_literal: true

class ProjectPost < ActiveRecord::Base
  include I18n::Alchemy
  include Shared::CommonWrapper
  has_notifications

  belongs_to :project, inverse_of: :posts
  belongs_to :reward
  belongs_to :user
  delegate :email_comment_html, to: :decorator

  before_save do
    reference_user
  end
  after_save :index_on_common

  validates_presence_of :user_id, :project_id, :comment_html, :title

  before_validation :reference_user

  scope :ordered, ->() { order('created_at desc') }

  def reference_user
    self.user_id = project.try(:user_id)
  end

  def to_partial_path
    'projects/posts/project_post'
  end

  def decorator
    @decorator ||= ProjectPostDecorator.new(self)
  end

  def common_index
    id_hash = common_id.present? ? {id: common_id} : {}

    {
      external_id: id,
      project_id: project.common_id,
      reward_id: reward.try(:common_id),
      current_ip: project.user.current_sign_in_ip,
      comment_html: comment_html,
      title: title,
{'fraction_non_alphanumeric': 0.08608949416342412, 'fraction_numerical': 0.0019455252918287938, 'mean_word_length': 4.004866180048662, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4301623', 'n_tokens_mistral': 708, 'n_tokens_neox': 688, 'n_words': 145}