index score, filter site_changed for compute

This commit is contained in:
Kyle Drake 2015-08-28 01:04:17 -07:00
parent a732cfda88
commit b75116d13c
2 changed files with 10 additions and 1 deletions

View file

@ -0,0 +1,9 @@
Sequel.migration do
up {
DB.add_index :sites, :score
}
down {
DB.drop_index :sites, :score
}
end

View file

@ -1077,7 +1077,7 @@ class Site < Sequel::Model
end end
def self.compute_scores def self.compute_scores
select(:id, :username, :created_at, :updated_at, :views, :featured_at, :changed_count).exclude(is_banned: true).exclude(is_crashing: true).exclude(is_nsfw: true).exclude(updated_at: nil).all.each do |s| select(:id, :username, :created_at, :updated_at, :views, :featured_at, :changed_count).exclude(is_banned: true).exclude(is_crashing: true).exclude(is_nsfw: true).exclude(updated_at: nil).where(site_changed: true).all.each do |s|
s.score = s.compute_score s.score = s.compute_score
s.save_changes validate: false s.save_changes validate: false
end end