tweaks to global feed

This commit is contained in:
Kyle Drake 2015-02-15 12:01:17 -08:00
parent d53b6584d5
commit 41a7cb763d
3 changed files with 20 additions and 2 deletions

View file

@ -14,7 +14,7 @@ get '/?' do
not_found if event.nil?
events_dataset = Event.where(id: params[:event_id]).paginate(1, 1)
elsif params[:activity] == 'global'
events_dataset = Event.select_all(:events).order(:created_at.desc).paginate(@current_page, 100).join_table(:inner, :sites, id: :site_id).where{views > 1500}.or(site_change_id: nil)
events_dataset = Event.global_dataset @current_page
else
events_dataset = current_site.news_feed(@current_page, 10)
end

View file

@ -12,6 +12,24 @@ class Event < Sequel::Model
many_to_one :site
many_to_one :actioning_site, key: :actioning_site_id, class: :Site
DEFAULT_GLOBAL_LIMIT = 100
GLOBAL_VIEWS_MINIMUM = 500
def self.global_dataset(current_page, limit=DEFAULT_GLOBAL_LIMIT)
select_all(:events).
order(:created_at.desc).
paginate(current_page, 100).
join_table(:inner, :sites, id: :site_id).
exclude(
Sequel.qualify(:sites, :is_deleted) => false,
:is_nsfw => false,
:is_banned => false,
:is_crashing => false
).
where{views > GLOBAL_VIEWS_MINIMUM}.
or(site_change_id: nil)
end
def created_by?(site)
return true if actioning_site_id == site.id
false