<commit_before>module Vidibus::Recording
  module Mongoid
    extend ActiveSupport::Concern

    class ProcessError < StandardError; end
    class StreamError < StandardError; end

    included do
      include ::Mongoid::Timestamps
      include Vidibus::Uuid::Mongoid

      embeds_many :parts, :as => :recording, :class_name => 'Vidibus::Recording::Part'

      field :name
      field :stream
      # field :live, :type => Boolean
      field :pid, :type => Integer
      field :info, :type => Hash
      field :size, :type => Integer
      field :duration, :type => Integer
      field :error
      field :scheduled_at, :type => DateTime
      field :started_at, :type => DateTime
      field :stopped_at, :type => DateTime
      field :failed_at, :type => DateTime
      field :running, :type => Boolean, :default => false
      field :monitoring_job_id, :type => String

      validates :name, :presence => true
      validates :stream, :format => {:with => /^rtmp.*?:\/\/.+$/}

      before_destroy :cleanup

      scope :ordered, desc(:started_at).desc(:created_at)
    end

    # Starts a recording job now, unless it has been done already.
    # Provide a Time object to schedule start.
    def start(time = :now)
      return false if done? || started?<commit_msg>Remove scope 'ordered'<commit_after>module Vidibus::Recording
  module Mongoid
    extend ActiveSupport::Concern

    class ProcessError < StandardError; end
    class StreamError < StandardError; end

    included do
      include ::Mongoid::Timestamps
      include Vidibus::Uuid::Mongoid

      embeds_many :parts, :as => :recording, :class_name => 'Vidibus::Recording::Part'

      field :name
      field :stream
      # field :live, :type => Boolean
      field :pid, :type => Integer
      field :info, :type => Hash
      field :size, :type => Integer
      field :duration, :type => Integer
      field :error
      field :scheduled_at, :type => DateTime
      field :started_at, :type => DateTime
      field :stopped_at, :type => DateTime
      field :failed_at, :type => DateTime
      field :running, :type => Boolean, :default => false
      field :monitoring_job_id, :type => String

      validates :name, :presence => true
      validates :stream, :format => {:with => /^rtmp.*?:\/\/.+$/}

      before_destroy :cleanup
    end

    # Starts a recording job now, unless it has been done already.
    # Provide a Time object to schedule start.
    def start(time = :now)
      return false if done? || started?
{'fraction_non_alphanumeric': 0.11710631494804156, 'fraction_numerical': 0.0, 'mean_word_length': 2.874613003095975, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 37, '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': '2209058', 'n_tokens_mistral': 751, 'n_tokens_neox': 720, 'n_words': 236}