sample from the top 1000 scored sites for featured

This commit is contained in:
Kyle Drake 2024-11-29 10:17:22 -06:00
parent eec3adfd23
commit 4876708d99

View file

@ -75,7 +75,7 @@ get '/?' do
end end
if SimpleCache.expired?(:featured_sites) if SimpleCache.expired?(:featured_sites)
@featured_sites = Site.order(:score.desc).exclude(is_nsfw: true).exclude(is_deleted: true).limit(12).all.shuffle.collect {|s| {screenshot_url: s.screenshot_url('index.html', '540x405'), uri: s.uri, title: s.title}} @featured_sites = Site.order(:score.desc).exclude(is_nsfw: true).exclude(is_deleted: true).limit(1000).all.sample(12).collect {|s| {screenshot_url: s.screenshot_url('index.html', '540x405'), uri: s.uri, title: s.title}}
SimpleCache.store :featured_sites, @featured_sites, 1.hour SimpleCache.store :featured_sites, @featured_sites, 1.hour
else else
@featured_sites = SimpleCache.get :featured_sites @featured_sites = SimpleCache.get :featured_sites