Skip to content

Commit

Permalink
Merge pull request #165 from robotmay/rankings-improvement
Browse files Browse the repository at this point in the history
Improvement for rankings and latest hotfixes
  • Loading branch information
Robert May committed Sep 13, 2013
2 parents e433846 + b4f99e5 commit 771f3c7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/collection_photograph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ def set_last_photo_added_at
end
end

after_destroy { collection.touch }
after_destroy { collection.try(:touch) }
end
3 changes: 2 additions & 1 deletion app/models/photograph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ def recommended(opts = {})
photo_ids = if opts[:n].present? && opts[:n] > 0
all_photo_ids = Photograph.rankings.revrange(0,(opts[:n] - 1))
else
all_photo_ids = Photograph.rankings.members.reverse
highest_score = Photograph.rankings.score(Photograph.rankings.last) || 1
all_photo_ids = Photograph.rankings.revrangebyscore(highest_score, 0.01)
Kaminari.paginate_array(all_photo_ids).page(opts[:page]).per(Photograph.default_per_page)
end

Expand Down

0 comments on commit 771f3c7

Please sign in to comment.