Revert "Comment sort preference: dual-write to migrate"

This reverts reddit/reddit@52d419fe73

It's now been over a month since we launched the new comment sort preference.
We've long ago hit the long tail of accounts needing a migration from the old
preference to the new one, and the ones that remain are either very inactive or
completely inactive (lost password, etc.), and thus, shouldn't really be
bothered much by getting put back on the default sort of "best" (`confidence`).
This commit is contained in:
xiongchiamiov
2015-05-20 11:18:09 -07:00
parent 64290bad0c
commit d5f1912ddf
5 changed files with 3 additions and 54 deletions

View File

@@ -194,7 +194,7 @@ class FrontController(RedditController):
comment=VCommentID('comment',
docs={"comment": "(optional) ID36 of a comment"}),
context=VInt('context', min=0, max=8),
sort=VTransitionaryMenu('controller'),
sort=VOneOf('sort', CommentSortMenu.visible_options()),
limit=VInt('limit',
docs={"limit": "(optional) an integer"}),
depth=VInt('depth',

View File

@@ -19,8 +19,6 @@
# All portions of the code written by reddit are Copyright (c) 2006-2015 reddit
# Inc. All Rights Reserved.
###############################################################################
from copy import copy
from pylons import c, g
from r2.config import feature
from r2.lib.menus import CommentSortMenu
@@ -103,15 +101,6 @@ def set_prefs(user, prefs):
setattr(user, k, v)
if k == 'pref_default_comment_sort':
# We have to do this copy-modify-assign shenanigans because if we
# just assign directly into `c.user.sort_options`, `Thing` doesn't
# know what happened and will wipe out our changes on save.
sort_options = copy(user.sort_options)
sort_options['front_sort'] = v
user.sort_options = sort_options
g.stats.simple_event('default_comment_sort.changed_in_prefs')
def filter_prefs(prefs, user):
# replace stylesheet_override with other_theme if it doesn't exist
if feature.is_enabled_for('stylesheets_everywhere', user):

View File

@@ -43,7 +43,6 @@ from r2.lib.souptest import (
from r2.lib.template_helpers import add_sr
from r2.lib.jsonresponse import JQueryResponse, JsonResponse
from r2.lib.log import log_text
from r2.lib.menus import CommentSortMenu
from r2.lib.permissions import ModeratorPermissionSet
from r2.models import *
from r2.models.promo import Location
@@ -1829,34 +1828,6 @@ class VMenu(Validator):
}
class VTransitionaryMenu(VMenu):
"""A temporary version of VMenu helping to transition to a new preference."""
def __init__(self, param):
# Our logic down below only makes sense for comment sorts, so let's
# hard-code that in as the menu.
VMenu.__init__(self, param, CommentSortMenu, remember=False)
def run(self, sort, where):
old_user_pref = c.user.sort_options.get('front_sort')
new_user_pref = c.user.pref_default_comment_sort
if c.user_is_loggedin and old_user_pref != new_user_pref:
# Even on view, if we catch an inconsistency between the
# preferences, we want to update them to match. This allows us to
# transition over to the new one without having to wait for people
# to change their sort.
c.user.pref_default_comment_sort = old_user_pref
c.user._commit()
g.stats.simple_event('default_comment_sort.synchronized')
# Was a valid sort provided?
if sort not in self.nav._options:
sort = c.user.default_comment_sort # Includes fallbacks
return sort
class VRatelimit(Validator):
def __init__(self, rate_user = False, rate_ip = False,
prefix = 'rate_', error = errors.RATELIMIT, *a, **kw):

View File

@@ -84,7 +84,7 @@ class Account(Thing):
pref_min_comment_score = -4,
pref_num_comments = g.num_comments,
pref_highlight_controversial=False,
pref_default_comment_sort = None,
pref_default_comment_sort = 'confidence',
pref_lang = g.lang,
pref_content_langs = (g.lang,),
pref_over_18 = False,
@@ -780,17 +780,6 @@ class Account(Thing):
def incr_admin_takedown_strikes(self, amt=1):
return self._incr('admin_takedown_strikes', amt)
@property
def default_comment_sort(self):
if self.pref_default_comment_sort:
return self.pref_default_comment_sort
old_sort_pref = self.sort_options.get('front_sort')
if old_sort_pref:
return old_sort_pref
return 'confidence'
class FakeAccount(Account):
_nodb = True

View File

@@ -61,7 +61,7 @@
<% menu = CommentSortMenu() %>
<select name="default_comment_sort">
%for sort in menu.visible_options():
<option ${'selected="selected"' if sort == c.user.default_comment_sort else ""}
<option ${'selected="selected"' if sort == c.user.pref_default_comment_sort else ""}
value="${sort}">
${menu.make_title(sort)}&#32;${_('(recommended)') if sort == menu._default else ''}
</option>