<commit_before>require 'acts_as_indexed'
require 'friendly_id'

module Refinery
  module Podcasts
    class Podcast < Refinery::Core::BaseModel
      self.table_name = 'refinery_podcasts'

      acts_as_indexed :fields => [:title, :author, :subtitle, :duration, :keywords, :summary]

      validates :title, :presence => true, :uniqueness => true

      belongs_to :file, :class_name => '::Refinery::Resource'
      belongs_to :image, :class_name => '::Refinery::Image'

      extend FriendlyId

      friendly_id :title, :use => :slugged

      def episode_number
        self.class.order('published_at DESC').
                   where(self.class.arel_table[:id].lteq(self.id)).
                   count
      end

      class << self
        def default_scope
          order "published_at DESC"
        end

        def published
          where arel_table[:published_at].lteq(Date.today)
        end

        def latest(limit = 10)
          published.limit limit
        end
      end<commit_msg>validate presence of podcast media file<commit_after>require 'acts_as_indexed'
require 'friendly_id'

module Refinery
  module Podcasts
    class Podcast < Refinery::Core::BaseModel
      self.table_name = 'refinery_podcasts'

      acts_as_indexed :fields => [:title, :author, :subtitle, :duration, :keywords, :summary]

      validates :title, :presence => true, :uniqueness => true

      belongs_to :file, :class_name => '::Refinery::Resource'
      belongs_to :image, :class_name => '::Refinery::Image'

      validates :file, presence: true

      extend FriendlyId

      friendly_id :title, :use => :slugged

      def episode_number
        self.class.order('published_at DESC').
                   where(self.class.arel_table[:id].lteq(self.id)).
                   count
      end

      class << self
        def default_scope
          order "published_at DESC"
        end

        def published
          where arel_table[:published_at].lteq(Date.today)
        end

        def latest(limit = 10)
          published.limit limit
        end
      end
{'fraction_non_alphanumeric': 0.10111272375423319, 'fraction_numerical': 0.0019351717464925011, 'mean_word_length': 2.4069192751235584, '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': '5145533', 'n_tokens_mistral': 631, 'n_tokens_neox': 605, 'n_words': 144}