fix site unblocking

This commit is contained in:
Kyle Drake 2022-11-12 13:07:49 -06:00
parent b54b2a4818
commit 6ea07df6a8
5 changed files with 39 additions and 13 deletions

View file

@ -68,28 +68,28 @@ def browse_sites_dataset
ds = ds.exclude featured_at: nil
ds = ds.order :featured_at.desc
when 'hits'
ds = ds.where{views > 100}
ds = ds.where{views > Site::BROWSE_MINIMUM_VIEWS}
ds = ds.order(:hits.desc, :site_updated_at.desc)
when 'views'
ds = ds.where{views > 100}
ds = ds.where{views > Site::BROWSE_MINIMUM_VIEWS}
ds = ds.order(:views.desc, :site_updated_at.desc)
when 'newest'
ds = ds.order(:created_at.desc, :views.desc)
when 'oldest'
ds = ds.where{views > 100}
ds = ds.where{views > Site::BROWSE_MINIMUM_VIEWS}
ds = ds.order(:created_at, :views.desc)
when 'random'
ds = ds.where{views > 100}
ds = ds.where{views > Site::BROWSE_MINIMUM_VIEWS}
ds = ds.where 'random() < 0.01'
when 'last_updated'
ds = ds.where{views > 100}
ds = ds.where{views > Site::BROWSE_MINIMUM_VIEWS}
params[:sort_by] = 'last_updated'
ds = ds.exclude(site_updated_at: nil)
ds = ds.order(:site_updated_at.desc, :views.desc)
when 'tipping_enabled'
ds = ds.where tipping_enabled: true
ds = ds.where("(tipping_paypal is not null and tipping_paypal != '') or (tipping_bitcoin is not null and tipping_bitcoin != '')")
ds = ds.where{views > 10_000}
ds = ds.where{views > Site::BROWSE_MINIMUM_FOLLOWER_VIEWS}
ds = ds.group :sites__id
ds = ds.order :follow_count.desc, :views.desc, :updated_at.desc
when 'blocks'
@ -100,7 +100,7 @@ def browse_sites_dataset
ds = ds.order :total.desc
else
params[:sort_by] = 'followers'
ds = ds.where{views > 10_000}
ds = ds.where{views > Site::BROWSE_MINIMUM_FOLLOWER_VIEWS}
ds = ds.order :follow_count.desc, :views.desc, :updated_at.desc
end

View file

@ -284,3 +284,15 @@ post '/site/:username/block' do |username|
redirect request.referer
end
end
get '/site/:username/unblock' do |username|
require_login
site = Site[username: username]
if site.nil? || current_site.id == site.id
redirect request.referer
end
current_site.unblock! site
redirect request.referer
end