email newsletter capability

This commit is contained in:
Kyle Drake 2015-06-28 21:41:08 -07:00
parent d4303c7e46
commit b986c57577
8 changed files with 169 additions and 1 deletions

View file

@ -118,6 +118,15 @@ class Site < Sequel::Model
maximum_site_files: 1000
)
def self.newsletter_sites
Site.select(:email).
exclude(email: 'nil').exclude(is_banned: true).
where{updated_at > EMAIL_BLAST_MAXIMUM_AGE}.
where{changed_count > 0}.
order(:updated_at.desc).
all
end
def too_many_files?(file_count=0)
(site_files_dataset.count + file_count) > plan_feature(:maximum_site_files)
end
@ -140,6 +149,14 @@ class Site < Sequel::Model
BROWSE_PAGINATION_LENGTH = 100
EMAIL_BLAST_MAXIMUM_AGE = 6.months.ago
if ENV['RACK_ENV'] == 'test'
EMAIL_BLAST_MAXIMUM_PER_DAY = 2
else
EMAIL_BLAST_MAXIMUM_PER_DAY = 2000
end
many_to_many :tags
one_to_many :profile_comments