Skip to content

Instantly share code, notes, and snippets.

@HashNuke
Forked from maxwell/reddit.rb
Created June 14, 2014 04:48
Show Gist options
  • Save HashNuke/b9a307873ea995b1efac to your computer and use it in GitHub Desktop.
Save HashNuke/b9a307873ea995b1efac to your computer and use it in GitHub Desktop.

Revisions

  1. @maxwell maxwell renamed this gist Jul 31, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @maxwell maxwell created this gist Jul 31, 2012.
    11 changes: 11 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    class Story < ActiveRecord::Base

    # make likes count whatever basic score you want. it would be the sum of up plus down votes, or use whatever cache counters you have and weight them accordingly.

    #the magic time should just be a unix time right before people started making stuff, for us, its just 6 months before we started makr.io

    def self.ranked
    order("(ln( 1 + posts.likes_count) + (EXTRACT(EPOCH FROM created_at) - 1327654606)/9000) desc")
    end

    end