<commit_before>Dir["#{Rails.root}/app/models/post/**/*.rb"].each {|x| require_dependency x}

class Post < ActiveRecord::Base
  STATUSES = %w(active pending flagged deleted)
  
  define_callbacks :delete
  define_callbacks :undelete
  has_many :notes, :order => "id desc"
  has_one :flag_detail, :class_name => "FlaggedPostDetail"
  belongs_to :user
  before_validation :set_random!, :on => :create
  before_create :set_index_timestamp!
  belongs_to :approver, :class_name => "User"
  attr_accessor :updater_ip_addr, :updater_user_id
  attr_accessor :metatag_flagged
  has_many :avatars, :class_name => "User", :foreign_key => "avatar_post_id"
  set_callback :delete, :before, :clear_avatars
  after_save :commit_flag
  has_and_belongs_to_many :_tags, :class_name => 'Tag'
  scope :available, where('status <> ?', 'deleted')
  scope :has_tag, lambda { |t| joins(:_tags).where(:tags => { :name => t }) }
  scope :has_tag_id, lambda { |t_id| joins(:_tags).where(:tags => { :id => t_id }) }

  # Finds posts which contains tags. Using operator and.
  # Options:
  #   :only_ids: set to true to only return array of ids.
  def self.has_tags(tags, options = {})
    tags = Array(tags).join(' & ')
    p_ids = Post.where('tags_index @@ to_tsquery(?)', tags);
    # Return the posts.
    if options[:only_ids]
      p_ids
    else
      Post.find(p_ids)
    end
  end

  include PostSqlMethods
  include PostCommentMethods
  include PostImageStoreMethods
  include PostVoteMethods
  include PostTagMethods
  include PostCountMethods
  include PostCacheMethods if CONFIG["enable_caching"]
  include PostParentMethods if CONFIG["enable_parent_posts"]
  include PostFileMethods
  include PostChangeSequenceMethods<commit_msg>Removed unused scope.<commit_after>Dir["#{Rails.root}/app/models/post/**/*.rb"].each {|x| require_dependency x}

class Post < ActiveRecord::Base
  STATUSES = %w(active pending flagged deleted)
  
  define_callbacks :delete
  define_callbacks :undelete
  has_many :notes, :order => "id desc"
  has_one :flag_detail, :class_name => "FlaggedPostDetail"
  belongs_to :user
  before_validation :set_random!, :on => :create
  before_create :set_index_timestamp!
  belongs_to :approver, :class_name => "User"
  attr_accessor :updater_ip_addr, :updater_user_id
  attr_accessor :metatag_flagged
  has_many :avatars, :class_name => "User", :foreign_key => "avatar_post_id"
  set_callback :delete, :before, :clear_avatars
  after_save :commit_flag
  has_and_belongs_to_many :_tags, :class_name => 'Tag'
  scope :available, where('status <> ?', 'deleted')
  scope :has_tag, lambda { |t| joins(:_tags).where(:tags => { :name => t }) }

  # Finds posts which contains tags. Using operator and.
  # Options:
  #   :only_ids: set to true to only return array of ids.
  def self.has_tags(tags, options = {})
    tags = Array(tags).join(' & ')
    p_ids = Post.where('tags_index @@ to_tsquery(?)', tags);
    # Return the posts.
    if options[:only_ids]
      p_ids
    else
      Post.find(p_ids)
    end
  end

  include PostSqlMethods
  include PostCommentMethods
  include PostImageStoreMethods
  include PostVoteMethods
  include PostTagMethods
  include PostCountMethods
  include PostCacheMethods if CONFIG["enable_caching"]
  include PostParentMethods if CONFIG["enable_parent_posts"]
  include PostFileMethods
  include PostChangeSequenceMethods
{'fraction_non_alphanumeric': 0.11429424052521635, 'fraction_numerical': 0.0, 'mean_word_length': 4.720136518771331, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, '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': '7614616', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1110, 'n_words': 270}