Choose a random package for the main page to ask for screenshots

This commit is contained in:
Christoph Haas 2021-03-14 16:40:01 +01:00
parent 4e07bf00fd
commit 7e7b40f412

View file

@ -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