<commit_before># encoding: utf-8

class Series < BaseModel
  SUBSCRIPTION_STATES = [
    SUBSCRIPTION_NEW           = 'New',
    SUBSCRIPTION_STARTED       = 'Started',
    SUBSCRIPTION_USER_APPROVED = 'User Approved',
    SUBSCRIPTION_PRX_APPROVED  = 'PRX Approved'
  ]

  include Storied

  acts_as_paranoid

  belongs_to :account, -> { with_deleted }
  belongs_to :creator, -> { with_deleted }, class_name: 'User', foreign_key: 'creator_id'

  has_many :stories, -> { order('episode_number DESC, position DESC, published_at DESC') }
  has_many :schedules

  has_one :image, -> { where(parent_id: nil) }, class_name: 'SeriesImage', dependent: :destroy

  before_validation :set_app_version, on: :create

  event_attribute :subscriber_only_at

  scope :v4, -> { where('`app_version` = ?', PRX::APP_VERSION) }

  scope :match_text, ->(text) {
    where("`series`.`title` like '%#{text}%' OR " +
          "`series`.`short_description` like '%#{text}%' OR " +
          "`series`.`description` like '%#{text}%'")
  }

  def subscribable?
    subscription_approval_status == SUBSCRIPTION_PRX_APPROVED
  end
<commit_msg>Add templates relation to series<commit_after># encoding: utf-8

class Series < BaseModel
  SUBSCRIPTION_STATES = [
    SUBSCRIPTION_NEW           = 'New',
    SUBSCRIPTION_STARTED       = 'Started',
    SUBSCRIPTION_USER_APPROVED = 'User Approved',
    SUBSCRIPTION_PRX_APPROVED  = 'PRX Approved'
  ]

  include Storied

  acts_as_paranoid

  belongs_to :account, -> { with_deleted }
  belongs_to :creator, -> { with_deleted }, class_name: 'User', foreign_key: 'creator_id'

  has_many :stories, -> { order('episode_number DESC, position DESC, published_at DESC') }
  has_many :schedules
  has_many :audio_version_templates

  has_one :image, -> { where(parent_id: nil) }, class_name: 'SeriesImage', dependent: :destroy

  before_validation :set_app_version, on: :create

  event_attribute :subscriber_only_at

  scope :v4, -> { where('`app_version` = ?', PRX::APP_VERSION) }

  scope :match_text, ->(text) {
    where("`series`.`title` like '%#{text}%' OR " +
          "`series`.`short_description` like '%#{text}%' OR " +
          "`series`.`description` like '%#{text}%'")
  }

  def subscribable?
    subscription_approval_status == SUBSCRIPTION_PRX_APPROVED
  end

{'fraction_non_alphanumeric': 0.13411970292704237, 'fraction_numerical': 0.0017474879860200961, 'mean_word_length': 4.032967032967033, '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': '72202', 'n_tokens_mistral': 824, 'n_tokens_neox': 799, 'n_words': 160}