<commit_before>class Tip < ActiveRecord::Base
    CATEGORIES = ["as", "with", "against"]
    
    belongs_to :gaming_object
    has_many :votes, dependent: :destroy
    belongs_to :user, foreign_key: :user_cookie, primary_key: :user_cookie

    validates :category, inclusion: { in: Character::CATEGORIES + Map::CATEGORIES, message: "%{value} is not a valid category" }
    validates :description, presence: true, length: { maximum: 1000 }
    
    scope :ordered_by_score, -> { joins(:votes).select("SUM(votes.weight) as score, tips.*").group('tips.id').order("score DESC") }
    
    if(Rails.env.production?)
        scope :ordered_by_vote_count, -> { joins(:votes).where("votes.weight > 0").where("votes.created_at" => (DateTime.now - 48.hours)..DateTime.now).select("COUNT(votes.id) - DATE_PART('days', NOW()::timestamp - tips.created_at::timestamp) as vote_count, tips.*").group('tips.id').order("vote_count DESC") }
    else
        scope :ordered_by_vote_count, -> { joins(:votes).where("votes.weight > 0").where("votes.created_at" => (DateTime.now - 48.hours)..DateTime.now).select("COUNT(votes.id) - (julianday('now') - julianday(tips.created_at)) as vote_count, tips.*").group('tips.id').order("vote_count DESC") }
    end
    
    scope :joins_last_vote, -> { joins(:votes).joins("LEFT OUTER JOIN votes other_votes ON votes.tip_id = other_votes.tip_id AND (votes.created_at < other_votes.created_at OR (votes.created_at = other_votes.created_at AND votes.id < other_votes.id))").where("other_votes.id IS NULL") }
    
    def score
       votes.sum(:weight)
    end
    
    def positive_score
        votes.positives.count
    end
    <commit_msg>doesn't limit the trending to only the 48h last votes<commit_after>class Tip < ActiveRecord::Base
    CATEGORIES = ["as", "with", "against"]
    
    belongs_to :gaming_object
    has_many :votes, dependent: :destroy
    belongs_to :user, foreign_key: :user_cookie, primary_key: :user_cookie

    validates :category, inclusion: { in: Character::CATEGORIES + Map::CATEGORIES, message: "%{value} is not a valid category" }
    validates :description, presence: true, length: { maximum: 1000 }
    
    scope :ordered_by_score, -> { joins(:votes).select("SUM(votes.weight) as score, tips.*").group('tips.id').order("score DESC") }
    
    if(Rails.env.production?)
        scope :ordered_by_vote_count, -> { joins(:votes).where("votes.weight > 0").select("COUNT(votes.id) - DATE_PART('days', NOW()::timestamp - tips.created_at::timestamp) as vote_count, tips.*").group('tips.id').order("vote_count DESC") }
    else
        scope :ordered_by_vote_count, -> { joins(:votes).where("votes.weight > 0").select("COUNT(votes.id) - (julianday('now') - julianday(tips.created_at)) as vote_count, tips.*").group('tips.id').order("vote_count DESC") }
    end
    
    scope :joins_last_vote, -> { joins(:votes).joins("LEFT OUTER JOIN votes other_votes ON votes.tip_id = other_votes.tip_id AND (votes.created_at < other_votes.created_at OR (votes.created_at = other_votes.created_at AND votes.id < other_votes.id))").where("other_votes.id IS NULL") }
    
    def score
       votes.sum(:weight)
    end
    
    def positive_score
        votes.positives.count
    end
    
{'fraction_non_alphanumeric': 0.15549348230912477, 'fraction_numerical': 0.00558659217877095, 'mean_word_length': 4.051724137931035, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '1408825', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1100, 'n_words': 211}