DEV: Remove all code referencing at_desktop bookmark reminders (#9650)

DEV: Remove all code referencing at_desktop bookmark reminders (#9650)

We have found no need for these reminder types, so we are removing the code for them.

diff --git a/app/assets/javascripts/discourse/app/controllers/bookmark.js b/app/assets/javascripts/discourse/app/controllers/bookmark.js
index 38ce4c7..992c322 100644
--- a/app/assets/javascripts/discourse/app/controllers/bookmark.js
+++ b/app/assets/javascripts/discourse/app/controllers/bookmark.js
@@ -175,14 +175,6 @@ export default Controller.extend(ModalFunctionality, {
     return isPresent(id);
   },
 
-  @discourseComputed()
-  showAtDesktop() {
-    return (
-      this.siteSettings.enable_bookmark_at_desktop_reminders &&
-      this.site.mobileView
-    );
-  },
-
   @discourseComputed("selectedReminderType")
   customDateTimeSelected(selectedReminderType) {
     return selectedReminderType === REMINDER_TYPES.CUSTOM;
@@ -346,8 +338,6 @@ export default Controller.extend(ModalFunctionality, {
     }
 
     switch (this.selectedReminderType) {
-      case REMINDER_TYPES.AT_DESKTOP:
-        return null;
       case REMINDER_TYPES.LATER_TODAY:
         return this.laterToday();
       case REMINDER_TYPES.NEXT_BUSINESS_DAY:
diff --git a/app/assets/javascripts/discourse/app/lib/bookmark.js b/app/assets/javascripts/discourse/app/lib/bookmark.js
index 8874034..ebad371 100644
--- a/app/assets/javascripts/discourse/app/lib/bookmark.js
+++ b/app/assets/javascripts/discourse/app/lib/bookmark.js
@@ -17,7 +17,6 @@ export function formattedReminderTime(reminderAt, timezone) {
 }
 
 export const REMINDER_TYPES = {
-  AT_DESKTOP: "at_desktop",
   LATER_TODAY: "later_today",
   NEXT_BUSINESS_DAY: "next_business_day",
   TOMORROW: "tomorrow",
diff --git a/app/assets/javascripts/discourse/app/templates/modal/bookmark.hbs b/app/assets/javascripts/discourse/app/templates/modal/bookmark.hbs
index 821ffe1..2cac81e 100644
--- a/app/assets/javascripts/discourse/app/templates/modal/bookmark.hbs
+++ b/app/assets/javascripts/discourse/app/templates/modal/bookmark.hbs
@@ -26,12 +26,6 @@
 
       {{#if userHasTimezoneSet}}
         {{#tap-tile-grid activeTile=selectedReminderType as |grid|}}
-          {{#if showAtDesktop}}
-            {{#tap-tile icon="desktop" tileId=reminderTypes.AT_DESKTOP activeTile=grid.activeTile onChange=(action "selectReminderType")}}
-              <div class="tap-tile-title">{{i18n "bookmarks.reminders.at_desktop"}}</div>
-            {{/tap-tile}}
-          {{/if}}
-
           {{#if showLaterToday}}
             {{#tap-tile icon="far-moon" tileId=reminderTypes.LATER_TODAY activeTile=grid.activeTile onChange=(action "selectReminderType")}}
               <div class="tap-tile-title">{{i18n "bookmarks.reminders.later_today"}}</div>
diff --git a/app/assets/javascripts/discourse/app/widgets/post-menu.js b/app/assets/javascripts/discourse/app/widgets/post-menu.js
index b02253a..376772c 100644
--- a/app/assets/javascripts/discourse/app/widgets/post-menu.js
+++ b/app/assets/javascripts/discourse/app/widgets/post-menu.js
@@ -306,8 +306,6 @@ registerButton("bookmark", attrs => {
       );
       title = "bookmarks.created_with_reminder";
       titleOptions.date = formattedReminder;
-    } else if (attrs.bookmarkReminderType === "at_desktop") {
-      title = "bookmarks.created_with_at_desktop_reminder";
     } else {
       title = "bookmarks.created";
     }
diff --git a/app/jobs/scheduled/bookmark_reminder_notifications.rb b/app/jobs/scheduled/bookmark_reminder_notifications.rb
index 4dca47c..cb7b016 100644
--- a/app/jobs/scheduled/bookmark_reminder_notifications.rb
+++ b/app/jobs/scheduled/bookmark_reminder_notifications.rb
@@ -6,9 +6,6 @@ module Jobs
   # Any leftovers will be caught in the next run, because the reminder_at column
   # is set to NULL once a reminder has been sent.
   class BookmarkReminderNotifications < ::Jobs::Scheduled
-    JOB_RUN_NUMBER_KEY ||= 'jobs_bookmark_reminder_notifications_job_run_num'
-    AT_DESKTOP_CONSISTENCY_RUN_NUMBER ||= 6
-
     every 5.minutes
 
     def self.max_reminder_notifications_per_run
@@ -21,88 +18,10 @@ module Jobs
     end
 
     def execute(args = nil)
-      bookmarks = Bookmark.pending_reminders
-        .where.not(reminder_type: Bookmark.reminder_types[:at_desktop])
-        .includes(:user).order('reminder_at ASC')
-
+      bookmarks = Bookmark.pending_reminders.includes(:user).order('reminder_at ASC')
       bookmarks.limit(BookmarkReminderNotifications.max_reminder_notifications_per_run).each do |bookmark|
         BookmarkReminderNotificationHandler.send_notification(bookmark)
       end
-
-      # we only want to ensure the desktop consistency every X runs of this job
-      # (every 30 mins in this case) so we don't bother redis too much, and the
-      # at desktop consistency problem should not really happen unless people
-      # are setting the "at desktop" reminder, going out for milk, and never coming
-      # back
-      current_job_run_number = Discourse.redis.get(JOB_RUN_NUMBER_KEY).to_i
-      if current_job_run_number == AT_DESKTOP_CONSISTENCY_RUN_NUMBER
-        ensure_at_desktop_consistency
-      end
-
-      increment_job_run_number(current_job_run_number)
-    end
-
-    def increment_job_run_number(current_job_run_number)
-      if current_job_run_number.zero? || current_job_run_number == AT_DESKTOP_CONSISTENCY_RUN_NUMBER
-        new_job_run_number = 1
-      else
-        new_job_run_number = current_job_run_number + 1
-      end
-      Discourse.redis.set(JOB_RUN_NUMBER_KEY, new_job_run_number)
-    end
-
-    def ensure_at_desktop_consistency
-      pending_at_desktop_bookmark_reminders = \
-        Bookmark.includes(:user)
-          .references(:user)
-          .pending_at_desktop_reminders
-          .where('users.last_seen_at >= :one_day_ago', one_day_ago: 1.day.ago.utc)
-
-      return if pending_at_desktop_bookmark_reminders.count.zero?
-
-      unique_users = pending_at_desktop_bookmark_reminders.map(&:user).uniq.map { |u| [u.id, u] }.flatten
-      unique_users = Hash[*unique_users]
-      pending_reminders_for_redis_check = unique_users.keys.map do |user_id|
-        "#{BookmarkReminderNotificationHandler::PENDING_AT_DESKTOP_KEY_PREFIX}#{user_id}"
-      end
-
-      Discourse.redis.mget(pending_reminders_for_redis_check).each.with_index do |value, idx|
-        next if value.present?
-        user_id = pending_reminders_for_redis_check[idx][/\d+/].to_i
-        user = unique_users[user_id]
-
-        user_pending_bookmark_reminders = pending_at_desktop_bookmark_reminders.select do |bookmark|
-          bookmark.user == user
-        end
-
-        user_expired_bookmark_reminders = user_pending_bookmark_reminders.select do |bookmark|
-          bookmark.reminder_set_at <= expiry_limit_datetime
-        end
-
-        next if user_pending_bookmark_reminders.length == user_expired_bookmark_reminders.length
-
-        # only tell the cache-gods that this user has pending "at desktop" reminders
-        # if they haven't let them all expire before coming back to their desktop
-        #
-        # the next time they visit the desktop the reminders will be cleared out once
-        # the notifications are sent
-        BookmarkReminderNotificationHandler.cache_pending_at_desktop_reminder(user)
-      end
-
-      clear_expired_at_desktop_reminders
-    end
-
-    def clear_expired_at_desktop_reminders
-      Bookmark
-        .pending_at_desktop_reminders
-        .where('reminder_set_at <= :expiry_limit_datetime', expiry_limit_datetime: expiry_limit_datetime)
-        .update_all(
-          reminder_set_at: nil, reminder_type: nil
-        )
-    end
-
-    def expiry_limit_datetime
-      BookmarkReminderNotificationHandler::PENDING_AT_DESKTOP_EXPIRY_DAYS.days.ago.utc
     end
   end
 end
diff --git a/app/models/bookmark.rb b/app/models/bookmark.rb
index 2dc9733..3cfae4f 100644
--- a/app/models/bookmark.rb
+++ b/app/models/bookmark.rb
@@ -6,8 +6,8 @@ class Bookmark < ActiveRecord::Base
   belongs_to :topic
 
   validates :reminder_at, presence: {

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

GitHub sha: fa572d3a

This commit appears in #9650 which was merged by martin.