From 9985bb663bf7f34f7b50413cf6261d28f7c53b68 Mon Sep 17 00:00:00 2001 From: Deimos Date: Wed, 12 Jun 2019 15:40:46 -0600 Subject: [PATCH] Change default time period to "all time" Previously, the default time period for topic listings under the Activity sort (which is the overall default) was set to 3 days. Part of the purpose of this was to stop long-lived, off-topic threads from sitting at the top of the site indefinitely. However, now that the Activity sort is adjusted to have a way to consider these threads "uninteresting" and prevent them from bumping, that's no longer necessary. We can try Activity/"all time" as the default sorting again, and should be able to resolve any issues through using the "uninteresting" judgments instead of trying to use the shorter time period to hide it. --- tildes/tildes/views/topic.py | 38 ++++++++++++------------------------ 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/tildes/tildes/views/topic.py b/tildes/tildes/views/topic.py index 9187425..e02b217 100644 --- a/tildes/tildes/views/topic.py +++ b/tildes/tildes/views/topic.py @@ -349,22 +349,16 @@ def post_comment_on_topic(request: Request, markdown: str) -> HTTPFound: def _get_default_settings(request: Request, order: Any) -> DefaultSettings: # noqa - if isinstance(request.context, Group): - is_home_page = False - - if request.user: - user_settings = ( - request.query(UserGroupSettings) - .filter( - UserGroupSettings.user == request.user, - UserGroupSettings.group == request.context, - ) - .one_or_none() + if isinstance(request.context, Group) and request.user: + user_settings = ( + request.query(UserGroupSettings) + .filter( + UserGroupSettings.user == request.user, + UserGroupSettings.group == request.context, ) - else: - user_settings = None + .one_or_none() + ) else: - is_home_page = True user_settings = None if user_settings and user_settings.default_order: @@ -388,17 +382,11 @@ def _get_default_settings(request: Request, order: Any) -> DefaultSettings: # n else: # Overall default periods, if the user doesn't have either a group-specific or a # home default set up: - # * "all time" if sorting by new - # * "all time" if sorting by activity and inside a group - # * "3 days" if sorting by activity and on home page - # * "1 day" otherwise (sorting by most votes or most comments) - if order == TopicSortOption.NEW: - default_period = None - elif order == TopicSortOption.ACTIVITY and not is_home_page: - default_period = None - elif order == TopicSortOption.ACTIVITY: - default_period = SimpleHoursPeriod(72) - else: + # * "1 day" if sorting by most votes or most comments + # * "all time" otherwise + if order in (TopicSortOption.VOTES, TopicSortOption.COMMENTS): default_period = SimpleHoursPeriod(24) + else: + default_period = None return DefaultSettings(order=default_order, period=default_period)