mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
experimenting with a new global activity feed
This commit is contained in:
parent
b66ecd5811
commit
92ed88cd9b
2 changed files with 24 additions and 2 deletions
|
@ -5,9 +5,11 @@ get '/activity' do
|
|||
global_dataset = Event.global_dataset
|
||||
|
||||
if params[:event_id]
|
||||
global_dataset.where! Sequel.qualify(:events, :id) => params[:event_id]
|
||||
global_dataset = global_dataset.where Sequel.qualify(:events, :id) => params[:event_id]
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
initial_events = global_dataset.all
|
||||
events = []
|
||||
|
||||
|
@ -47,5 +49,25 @@ get '/activity' do
|
|||
@events << event
|
||||
end
|
||||
|
||||
=end
|
||||
|
||||
|
||||
if SimpleCache.expired?(:activity_event_ids)
|
||||
|
||||
initial_events = Event.global_site_changes_dataset.limit(1000).all
|
||||
@events = []
|
||||
initial_events.each do |event|
|
||||
event_site = event.site
|
||||
next if @events.select {|e| e.site_id == event.site_id}.count >= 1
|
||||
next if event_site.is_a_jerk?
|
||||
next unless event_site.follows_dataset.count > 1
|
||||
@events.push event
|
||||
end
|
||||
|
||||
SimpleCache.store :activity_event_ids, @events.collect {|e| e.id}, 60.minutes
|
||||
else
|
||||
@events = Event.where(id: SimpleCache.get(:activity_event_ids)).order(:created_at.desc).all
|
||||
end
|
||||
|
||||
erb :'activity'
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ class Event < Sequel::Model
|
|||
|
||||
DEFAULT_GLOBAL_LIMIT = 300
|
||||
GLOBAL_VIEWS_MINIMUM = 5
|
||||
GLOBAL_VIEWS_SITE_CHANGE_MINIMUM = 1000
|
||||
GLOBAL_VIEWS_SITE_CHANGE_MINIMUM = 3_000
|
||||
|
||||
def self.news_feed_default_dataset
|
||||
if SimpleCache.expired?(:excluded_actioning_site_ids)
|
||||
|
|
Loading…
Add table
Reference in a new issue