Remove daily mailing mode option as it doesn't scale.

Remove daily mailing mode option as it doesn’t scale.

"Daily updates" option for mailing list mode - feature - Discourse Meta

diff --git a/app/assets/javascripts/discourse/controllers/preferences/emails.js.es6 b/app/assets/javascripts/discourse/controllers/preferences/emails.js.es6
index db25acc..74b1d76 100644
--- a/app/assets/javascripts/discourse/controllers/preferences/emails.js.es6
+++ b/app/assets/javascripts/discourse/controllers/preferences/emails.js.es6
@@ -30,7 +30,6 @@ export default Ember.Controller.extend(PreferencesTabController, {
   @computed()
   mailingListModeOptions() {
     return [
-      {name: I18n.t('user.mailing_list_mode.daily'), value: 0},
       {name: this.get('frequencyEstimate'), value: 1},
       {name: I18n.t('user.mailing_list_mode.individual_no_echo'), value: 2}
     ];
diff --git a/app/jobs/scheduled/enqueue_mailing_list_emails.rb b/app/jobs/scheduled/enqueue_mailing_list_emails.rb
deleted file mode 100644
index 1f4562d..0000000
--- a/app/jobs/scheduled/enqueue_mailing_list_emails.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-module Jobs
-
-  class EnqueueMailingListEmails < Jobs::Scheduled
-    every 1.hour
-
-    def execute(args)
-      return if SiteSetting.disable_mailing_list_mode?
-      target_user_ids.each do |user_id|
-        Jobs.enqueue(:user_email, type: :mailing_list, user_id: user_id)
-      end
-    end
-
-    def target_user_ids
-      # Users who want to receive daily mailing list emails
-      User.real
-          .activated
-          .not_suspended
-          .not_blocked
-          .joins(:user_option)
-          .where(staged: false, user_options: { mailing_list_mode: true, mailing_list_mode_frequency: 0 })
-          .where("#{!SiteSetting.must_approve_users?} OR approved OR moderator OR admin")
-          .where("date_part('hour', first_seen_at) = date_part('hour', CURRENT_TIMESTAMP)")           # where the hour of first_seen_at is the same as the current hour
-          .where("COALESCE(first_seen_at, '2010-01-01') <= CURRENT_TIMESTAMP - '23 HOURS'::INTERVAL") # don't send unless you've been around for a day already
-          .pluck(:id)
-    end
-
-  end
-
-end
diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb
index 0f91088..d96d0ec 100644
--- a/app/mailers/user_notifications.rb
+++ b/app/mailers/user_notifications.rb
@@ -75,39 +75,6 @@ class UserNotifications < ActionMailer::Base
     end
   end
 
-  # This is the "mailing list summary email"
-  def mailing_list(user, opts={})
-    @since = opts[:since] || 1.day.ago
-    @since_formatted = short_date(@since)
-
-    topics = Topic
-      .joins(:posts)
-      .includes(:posts)
-      .for_digest(user, 100.years.ago)
-      .where("posts.created_at > ?", @since)
-
-    unless user.staff?
-      topics = topics.where("posts.post_type <> ?", Post.types[:whisper])
-    end
-
-    @new_topics = topics.where("topics.created_at > ?", @since).uniq
-    @existing_topics = topics.where("topics.created_at <= ?", @since).uniq
-    @topics = topics.uniq
-
-    return if @topics.empty?
-
-    build_summary_for(user)
-    opts = {
-      from_alias: I18n.t('user_notifications.mailing_list.from', site_name: SiteSetting.title),
-      subject: I18n.t('user_notifications.mailing_list.subject_template', email_prefix: @email_prefix, date: @date),
-      mailing_list_mode: true,
-      add_unsubscribe_link: true,
-      unsubscribe_url: "#{Discourse.base_url}/email/unsubscribe/#{@unsubscribe_key}",
-    }
-
-    apply_notification_styles(build_email(@user.email, opts))
-  end
-
   def digest(user, opts={})
     build_summary_for(user)
     min_date = opts[:since] || user.last_emailed_at || user.last_seen_at || 1.month.ago
diff --git a/app/models/mailing_list_mode_site_setting.rb b/app/models/mailing_list_mode_site_setting.rb
index 9a8241c..ea0161d 100644
--- a/app/models/mailing_list_mode_site_setting.rb
+++ b/app/models/mailing_list_mode_site_setting.rb
@@ -8,7 +8,6 @@ class MailingListModeSiteSetting < EnumSiteSetting
 
   def self.values
     @values ||= [
-      { name: 'user.mailing_list_mode.daily',      value:  0 },
       { name: 'user.mailing_list_mode.individual', value:  1 },
       { name: 'user.mailing_list_mode.individual_no_echo', value:  2 }
     ]
diff --git a/app/models/user_option.rb b/app/models/user_option.rb
index 7ef3b52..0a1cb1c 100644
--- a/app/models/user_option.rb
+++ b/app/models/user_option.rb
@@ -155,8 +155,8 @@ end
 #  email_previous_replies           :integer          default(2), not null
 #  email_in_reply_to                :boolean          default(TRUE), not null
 #  like_notification_frequency      :integer          default(1), not null
+#  mailing_list_mode_frequency      :integer          default(1), not null
 #  include_tl0_in_digests           :boolean          default(FALSE)
-#  mailing_list_mode_frequency      :integer          default(0), not null
 #
 # Indexes
 #
diff --git a/app/views/user_notifications/mailing_list.html.erb b/app/views/user_notifications/mailing_list.html.erb
deleted file mode 100644
index 076204d..0000000
--- a/app/views/user_notifications/mailing_list.html.erb
+++ /dev/null
@@ -1,79 +0,0 @@
-<div id="top"></div>
-<table style='width: 100%; border: 20px solid #eee;' cellspacing='0' cellpadding='0'>
-  <thead>
-    <td style='padding: 10px 10px; background-color: #<%= @header_bgcolor %>;'>
-      <a href='<%= Discourse.base_url %>' style='color: #<%= @anchor_color %>'>
-        <% if logo_url.blank? %>
-          <%= SiteSetting.title %>
-        <% else %>
-          <img src='<%= logo_url %>' style='max-height: 35px; min-height: 35px; height: 35px;' class='site-logo'></a>
-        <% end %>
-        <br />
-        <div style='padding-top: 10px;'>
-          <%= raw(t 'user_notifications.mailing_list.why', site_link: html_site_link(@anchor_color), date: @since_formatted) %>
-        </div>
-        <hr />
-      </a>
-    </td>
-  </thead>
-  <tr>
-    <td>
-      <h4 style="padding: 0 25px; margin: 10px 0;"><%= t('user_notifications.mailing_list.new_topics') %></h3>
-      <ul>
-        <% @new_topics.each do |topic| %>
-          <%= mailing_list_topic(topic, topic.posts.length) %>
-        <% end %>
-      </ul>
-      <h4 style="padding: 0 25px; margin: 10px 0;"><%= t('user_notifications.mailing_list.topic_updates') %></h3>
-      <ul>
-        <% @existing_topics.each do |topic| %>
-          <%= mailing_list_topic(topic, topic.posts.length) %>
-        <% end %>
-      </ul>
-    </td>
-  </tr>
-</table>
-<table style='width: 100%; background: #eee;' cellspacing='0' cellpadding='0'>
-  <% @topics.each do |topic| %>
-    <tr>
-      <td>
-        <h3 style='padding: 20px 20px 10px; margin: 0;'>
-          <%= email_topic_link(topic) %>
-        </h3>
-      </td>
-    </tr>
-    <%- unless SiteSetting.private_email? %>
-      <tr>
-        <td style='border-left: 20px solid #eee; border-right: 20px solid #eee; border-bottom: 10px solid #eee; padding: 10px 10px; background: #fff;'>
-          <% topic.posts.each do |post| %>
-            <div>
-              <img style="float: left; width: 20px; padding-right: 5px;" src="<%= post.user.small_avatar_url %>" title="<%= post.user.username%>">
-              <p style="font-size: 15px; color: #888">
-                <a href='<%= "#{Discourse.base_url}/u/#{post.user.username}" %>'>
-                  <%- if show_username_on_post(post) %>
-                    <%= post.user.username %>
-                  <% end %>
-
-                  <%- if show_name_on_post(post) %>
-                    - <%= post.user.name %>
-                  <% end %>
-                </a>
-
-                <span> - </span>
-                <span><%= I18n.l(post.created_at, format: :long) %></span>
-              </p>
-              <%= raw format_for_email(post, false) %>
-              <hr />
-            </div>
-          <% end %>
-          <a style='font-size: 12px; float: right;' href='<%= Discourse.base_url + topic.relative_url %>'><%= t('user_notifications.mailing_list.view_this_topic') %></a>
-        </td>
-      </tr>
-      <tr>

[... diff too long, it was truncated ...]

GitHub sha: 71a266b6