mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
Merge branch 'master' of github.com:neocities/neocities
This commit is contained in:
commit
9e5dbfa2c6
2 changed files with 9 additions and 2 deletions
|
@ -200,6 +200,12 @@ class Site < Sequel::Model
|
|||
|
||||
one_to_many :archives
|
||||
|
||||
def self.supporter_ids
|
||||
parent_supporters = DB[%{SELECT id FROM sites WHERE plan_type IS NOT NULL AND plan_type != 'free'}].all.collect {|s| s[:id]}
|
||||
child_supporters = DB[%{select a.id as id from sites a, sites b where a.parent_site_id is not null and a.parent_site_id=b.id and (a.plan_type != 'free' or b.plan_type != 'free')}].all.collect {|s| s[:id]}
|
||||
parent_supporters + child_supporters
|
||||
end
|
||||
|
||||
def self.newsletter_sites
|
||||
Site.select(:email).
|
||||
exclude(email: 'nil').exclude(is_banned: true).
|
||||
|
|
|
@ -12,8 +12,9 @@ class Stat < Sequel::Model
|
|||
class << self
|
||||
def prune!
|
||||
DB[
|
||||
"DELETE FROM stats WHERE created_at < ? AND site_id NOT IN (SELECT id FROM sites WHERE plan_type IS NOT NULL OR plan_type != 'free')",
|
||||
(FREE_RETAINMENT_DAYS-1).days.ago.to_date.to_s
|
||||
"DELETE FROM stats WHERE created_at < ? AND site_id NOT IN ?",
|
||||
(FREE_RETAINMENT_DAYS-1).days.ago.to_date.to_s,
|
||||
Site.supporter_ids
|
||||
].first
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue