throw a short temp cache around excluded_actioning_site_ids

This commit is contained in:
Kyle Drake 2017-04-02 22:42:32 -07:00
parent 9d9ada3acc
commit 07be2dcecc

View file

@ -17,7 +17,12 @@ class Event < Sequel::Model
GLOBAL_VIEWS_SITE_CHANGE_MINIMUM = 1000 GLOBAL_VIEWS_SITE_CHANGE_MINIMUM = 1000
def self.news_feed_default_dataset def self.news_feed_default_dataset
excluded_actioning_site_ids = DB[%{select distinct(actioning_site_id) from events join sites on actioning_site_id=sites.id where sites.is_banned='t' or sites.is_nsfw='t' or sites.is_deleted='t'}].all.collect {|r| r[:actioning_site_id]} if SimpleCache.expired?(:excluded_actioning_site_ids)
res = DB[%{select distinct(actioning_site_id) from events join sites on actioning_site_id=sites.id where sites.is_banned='t' or sites.is_nsfw='t' or sites.is_deleted='t'}].all.collect {|r| r[:actioning_site_id]}
excluded_actioning_site_ids = SimpleCache.store :excluded_actioning_site_ids, res, 10.minutes
else
excluded_actioning_site_ids = SimpleCache.get :excluded_actioning_site_ids
end
ds = select_all(:events). ds = select_all(:events).
order(:created_at.desc). order(:created_at.desc).