<commit_before># flag_promotions/app/models/promoted_item.rb
class PromotedItem < ActiveRecord::Base
  belongs_to :product

  validates :product, :presence => true

  has_attached_file :background,
                    :styles => { :normal => '990x530>' },
                    :default_style => :normal,
                    :path => SpreeFlagPromotions.s3? ? 'assets/products/:id/bg/:style/:basename.:extension' : ':rails_root/public/assets/products/:id/bg/:style/:basename.:extension',
                    :url => '/assets/products/:id/bg/:style/:basename.:extension',
                    :storage => SpreeFlagPromotions.s3? ? 's3' : 'filesystem',
                    :s3_credentials => SpreeFlagPromotions.s3_yml_file,
                    :default_url => "/images/blank.png"
  has_attached_file :image,
                    :styles => { :normal => '990x530>' },
                    :default_style => :normal,
                    :path => SpreeFlagPromotions.s3? ? 'assets/products/:id/image/:style/:basename.:extension' : ':rails_root/public/assets/products/:id/image/:style/:basename.:extension',
                    :url => '/assets/products/:id/image/:style/:basename.:extension',
                    :storage => SpreeFlagPromotions.s3? ? 's3' : 'filesystem',
                    :s3_credentials => SpreeFlagPromotions.s3_yml_file,
                    :default_url => "/images/blank.png"


  scope :valid, where('start_date <= :start_date AND end_date >= :end_date', {:start_date => Time.now, :end_date => Time.now})

  def name
    product.nil? ? 'ERR' : product.name
  end
end<commit_msg>Add a sorted scope.<commit_after># flag_promotions/app/models/promoted_item.rb
class PromotedItem < ActiveRecord::Base
  belongs_to :product

  validates :product, :presence => true

  has_attached_file :background,
                    :styles => { :normal => '990x530>' },
                    :default_style => :normal,
                    :path => SpreeFlagPromotions.s3? ? 'assets/products/:id/bg/:style/:basename.:extension' : ':rails_root/public/assets/products/:id/bg/:style/:basename.:extension',
                    :url => '/assets/products/:id/bg/:style/:basename.:extension',
                    :storage => SpreeFlagPromotions.s3? ? 's3' : 'filesystem',
                    :s3_credentials => SpreeFlagPromotions.s3_yml_file,
                    :default_url => "/images/blank.png"
  has_attached_file :image,
                    :styles => { :normal => '990x530>' },
                    :default_style => :normal,
                    :path => SpreeFlagPromotions.s3? ? 'assets/products/:id/image/:style/:basename.:extension' : ':rails_root/public/assets/products/:id/image/:style/:basename.:extension',
                    :url => '/assets/products/:id/image/:style/:basename.:extension',
                    :storage => SpreeFlagPromotions.s3? ? 's3' : 'filesystem',
                    :s3_credentials => SpreeFlagPromotions.s3_yml_file,
                    :default_url => "/images/blank.png"


  scope :valid, where('start_date <= :start_date AND end_date >= :end_date', {:start_date => Time.now, :end_date => Time.now})
  scope :sorted, order(:position)

  def name
    product.nil? ? 'ERR' : product.name
  end
end
{'fraction_non_alphanumeric': 0.15065096094234345, 'fraction_numerical': 0.013639181649101054, 'mean_word_length': 2.389705882352941, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 47, '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': '4009660', 'n_tokens_mistral': 1021, 'n_tokens_neox': 976, 'n_words': 147}