<commit_before>module Shoppe
  class Order < ActiveRecord::Base
    # An array of all the available statuses for an order
    STATUSES = %w(building confirming received accepted rejected shipped).freeze

    # The Shoppe::User who accepted the order
    #
    # @return [Shoppe::User]
    belongs_to :accepter, class_name: 'Shoppe::User', foreign_key: 'accepted_by'

    # The Shoppe::User who rejected the order
    #
    # @return [Shoppe::User]
    belongs_to :rejecter, class_name: 'Shoppe::User', foreign_key: 'rejected_by'

    # Validations
    validates :status, inclusion: { in: STATUSES }

    # Set the status to building if we don't have a status
    after_initialize { self.status = STATUSES.first if status.blank? }

    # All orders which have been received
    scope :received, -> { where('received_at is not null') }

    # All orders which are being built or confirming
    scope :building, -> { where('received_at is null') }

    # All orders which are currently pending acceptance/rejection
    scope :pending, -> { where(status: 'received') }

    # All ordered ordered by their ID desending
    scope :ordered, -> { order(id: :desc) }

    # All orders which have been completed
    scope :completed, -> { where(status: %w{received accepted rejected shipped}) }

    # Is this order still being built by the user?
    #
    # @return [Boolean]
    def building?
      status == 'building'
    end

    # Is this order in the user confirmation step?
    #
    # @return [Boolean]
    def confirming?
      status == 'confirming'
    end

    # Has this order been rejected?
    #
    # @return [Boolean]
    def rejected?
      !!rejected_at
    end

    # Has this order been accepted?
    #
    # @return [Boolean]
    def accepted?
      !!accepted_at<commit_msg>fix completed scope algorithm<commit_after>module Shoppe
  class Order < ActiveRecord::Base
    # An array of all the available statuses for an order
    STATUSES = %w(building confirming received accepted rejected shipped).freeze

    # The Shoppe::User who accepted the order
    #
    # @return [Shoppe::User]
    belongs_to :accepter, class_name: 'Shoppe::User', foreign_key: 'accepted_by'

    # The Shoppe::User who rejected the order
    #
    # @return [Shoppe::User]
    belongs_to :rejecter, class_name: 'Shoppe::User', foreign_key: 'rejected_by'

    # Validations
    validates :status, inclusion: { in: STATUSES }

    # Set the status to building if we don't have a status
    after_initialize { self.status = STATUSES.first if status.blank? }

    # All orders which have been received
    scope :received, -> { where('received_at is not null') }

    # All orders which are being built or confirming
    scope :building, -> { where('received_at is null') }

    # All orders which are currently pending acceptance/rejection
    scope :pending, -> { where(status: 'received') }

    # All ordered ordered by their ID desending
    scope :ordered, -> { order(id: :desc) }

    # All orders which have been completed
    scope :completed, -> { where(status: %w{received accepted shipped}) }

    # Is this order still being built by the user?
    #
    # @return [Boolean]
    def building?
      status == 'building'
    end

    # Is this order in the user confirmation step?
    #
    # @return [Boolean]
    def confirming?
      status == 'confirming'
    end

    # Has this order been rejected?
    #
    # @return [Boolean]
    def rejected?
      !!rejected_at
    end

    # Has this order been accepted?
    #
    # @return [Boolean]
    def accepted?
      !!accepted_at
{'fraction_non_alphanumeric': 0.09656712252302539, 'fraction_numerical': 0.0, 'mean_word_length': 2.934138309549945, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '2742346', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1016, 'n_words': 369}