Choose a random package for the main page to ask for screenshots
This commit is contained in:
parent
4e07bf00fd
commit
7e7b40f412
1 changed files with 5 additions and 1 deletions
|
|
@ -6,7 +6,11 @@ class WelcomeController < ApplicationController
|
|||
|
||||
@package_count = Package.count
|
||||
|
||||
@most_wanted_package = Package.without_screenshots.order(visits: :desc).first
|
||||
# Get up 100 screenshots where the packages have the most visits
|
||||
query = Package.without_screenshots.order(visits: :desc)
|
||||
count = query.count
|
||||
random_offset = rand( [100, count].min )
|
||||
@most_wanted_package = query.offset(random_offset).first
|
||||
end
|
||||
|
||||
def about
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue