<commit_before>class Project < ActiveRecord::Base
  # Includes

  # Before, after callbacks
  after_create :update_rss_record, if: Proc.new { |p| p.is_published? }
  after_update :update_rss_record, if: Proc.new { |p| !p.is_published_was && p.is_published? }

  # Default scopes, default values (e.g. self.per_page =)
  PER_PAGE = 50

  # Associations: belongs_to > has_one > has_many > has_and_belongs_to_many
  has_many :photos, as: :owner, dependent: :destroy

  # Validations: presence > by type > validates
  validates_presence_of :title, :info, :description

  # Other properties (e.g. accepts_nested_attributes_for)
  attr_accessible :title, :is_published, :description, :weight, :info, :photos_attributes

  accepts_nested_attributes_for :photos, :allow_destroy => true

  # Model dictionaries, state machine

  # Scopes

  class << self
  end

  # Other model methods

  ##
  # Get first cover photo of a project
  #
  # Returns {Photo}
  #
  def cover_photo
    cover_photo = self.photos.where(is_cover: true).order('photos.created_at ASC').first
    unless cover_photo
      cover_photo = self.photos.order('photos.created_at ASC').first<commit_msg>reject empty new photo attributes<commit_after>class Project < ActiveRecord::Base
  # Includes

  # Before, after callbacks
  after_create :update_rss_record, if: Proc.new { |p| p.is_published? }
  after_update :update_rss_record, if: Proc.new { |p| !p.is_published_was && p.is_published? }

  # Default scopes, default values (e.g. self.per_page =)
  PER_PAGE = 50

  # Associations: belongs_to > has_one > has_many > has_and_belongs_to_many
  has_many :photos, as: :owner, dependent: :destroy

  # Validations: presence > by type > validates
  validates_presence_of :title, :info, :description

  # Other properties (e.g. accepts_nested_attributes_for)
  attr_accessible :title, :is_published, :description, :weight, :info, :photos_attributes

  accepts_nested_attributes_for :photos, :allow_destroy => true, reject_if: proc { |a| !a.has_key?('id') && !a.has_key?('asset') }

  # Model dictionaries, state machine

  # Scopes

  class << self
  end

  # Other model methods

  ##
  # Get first cover photo of a project
  #
  # Returns {Photo}
  #
  def cover_photo
    cover_photo = self.photos.where(is_cover: true).order('photos.created_at ASC').first
    unless cover_photo
      cover_photo = self.photos.order('photos.created_at ASC').first
{'fraction_non_alphanumeric': 0.10884918986289988, 'fraction_numerical': 0.0016618196925633569, 'mean_word_length': 4.387024608501118, 'pattern_counts': {'":': 0, '<': 9, '<?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': '3702674', 'n_tokens_mistral': 833, 'n_tokens_neox': 782, 'n_words': 196}