mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
ensure stats for supporter children are retained
This commit is contained in:
parent
10018c5124
commit
3057eda4b0
2 changed files with 9 additions and 2 deletions
|
@ -200,6 +200,12 @@ class Site < Sequel::Model
|
||||||
|
|
||||||
one_to_many :archives
|
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
|
def self.newsletter_sites
|
||||||
Site.select(:email).
|
Site.select(:email).
|
||||||
exclude(email: 'nil').exclude(is_banned: true).
|
exclude(email: 'nil').exclude(is_banned: true).
|
||||||
|
|
|
@ -12,8 +12,9 @@ class Stat < Sequel::Model
|
||||||
class << self
|
class << self
|
||||||
def prune!
|
def prune!
|
||||||
DB[
|
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')",
|
"DELETE FROM stats WHERE created_at < ? AND site_id NOT IN ?",
|
||||||
(FREE_RETAINMENT_DAYS-1).days.ago.to_date.to_s
|
(FREE_RETAINMENT_DAYS-1).days.ago.to_date.to_s,
|
||||||
|
Site.supporter_ids
|
||||||
].first
|
].first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue