mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
index for suggestions, only load when needed
This commit is contained in:
parent
ae3df1d0f9
commit
16673f0111
4 changed files with 11 additions and 4 deletions
|
@ -4,8 +4,6 @@ get '/?' do
|
|||
|
||||
redirect '/dashboard' if current_site.is_education
|
||||
|
||||
@suggestions = current_site.suggestions
|
||||
|
||||
@page = params[:page].to_i
|
||||
@page = 1 if @page == 0
|
||||
|
||||
|
|
9
migrations/113_site_suggestions_index.rb
Normal file
9
migrations/113_site_suggestions_index.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
Sequel.migration do
|
||||
up {
|
||||
DB.add_index :sites, [:follow_count, :updated_at, :views]
|
||||
}
|
||||
|
||||
down {
|
||||
DB.drop_index :sites, [:follow_count, :updated_at, :views]
|
||||
}
|
||||
end
|
|
@ -1466,7 +1466,7 @@ class Site < Sequel::Model
|
|||
end
|
||||
|
||||
def suggestions(limit=SUGGESTIONS_LIMIT, offset=0)
|
||||
suggestions_dataset = Site.exclude(id: id).exclude(is_banned: true).exclude(is_nsfw: true).order(:views.desc, :updated_at.desc)
|
||||
suggestions_dataset = Site.exclude(id: id).exclude(is_deleted: true).exclude(is_nsfw: true).order(:views.desc, :updated_at.desc)
|
||||
suggestions = suggestions_dataset.where(tags: tags).limit(limit, offset).all
|
||||
|
||||
return suggestions if suggestions.length == limit
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
<% if site.followings_dataset.count == 0 %>
|
||||
<% if !@events.empty? %><h2>Sites to Follow</h2><% end %>
|
||||
<ul class="row website-Gallery content int-Gall suggestions">
|
||||
<% @suggestions.each do |suggested_site| %>
|
||||
<% current_site.suggestions.each do |suggested_site| %>
|
||||
<li>
|
||||
<a href="<%= suggested_site.uri %>" class="neo-Screen-Shot" title="<%= suggested_site.title %>">
|
||||
<span class="img-Holder" style="background:url(<%= suggested_site.screenshot_url('index.html', '540x405') %>) no-repeat;">
|
||||
|
|
Loading…
Add table
Reference in a new issue