Skip to content

Instantly share code, notes, and snippets.

@HashNuke
Forked from abitdodgy/hot_algorithm.md
Created June 26, 2014 05:55
Show Gist options
  • Select an option

  • Save HashNuke/904064494eec30648e6c to your computer and use it in GitHub Desktop.

Select an option

Save HashNuke/904064494eec30648e6c to your computer and use it in GitHub Desktop.

Revisions

  1. @abitdodgy abitdodgy revised this gist Jun 20, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion hot_algorithm.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    A sorting algorithm for sorting by hot, roughly based on Reddit with a few tweeks.
    A sorting algorithm for sorting by "hotness", roughly based on Reddit's algorithm with a few tweeks.

    ````ruby
    scope :order_by_hot, ->
  2. @abitdodgy abitdodgy revised this gist Jun 20, 2013. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions hot_algorithm.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    A sorting algorithm for sorting by hot, roughly based on Reddit with a few tweeks.

    ````ruby
    scope :order_by_hot, ->
    { order("round((votes_count - 1) / POW(DATE_PART('day', Now() - created_at) * 24 + DATE_PART('hour', Now() - created_at) + 2, 1.5)::numeric, 8) DESC, votes_count DESC") }
  3. @abitdodgy abitdodgy revised this gist Jun 20, 2013. 1 changed file with 1 addition and 4 deletions.
    5 changes: 1 addition & 4 deletions hot_algorithm.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,4 @@

    ````ruby
    scope :order_by_hot, ->
    { order("
    round((votes_count - 1) / POW(DATE_PART('day', Now() - created_at) * 24 + DATE_PART('hour', Now() - created_at) + 2, 1.5)::numeric, 8) DESC,
    votes_count DESC") }
    { order("round((votes_count - 1) / POW(DATE_PART('day', Now() - created_at) * 24 + DATE_PART('hour', Now() - created_at) + 2, 1.5)::numeric, 8) DESC, votes_count DESC") }
    ````
  4. @abitdodgy abitdodgy created this gist Jun 20, 2013.
    7 changes: 7 additions & 0 deletions hot_algorithm.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@

    ````ruby
    scope :order_by_hot, ->
    { order("
    round((votes_count - 1) / POW(DATE_PART('day', Now() - created_at) * 24 + DATE_PART('hour', Now() - created_at) + 2, 1.5)::numeric, 8) DESC,
    votes_count DESC") }
    ````