From c0802c9c043cb3a738a691449c0a00d4b4d3af8f Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 7 Jun 2024 22:43:28 -0400 Subject: [PATCH] cleanup legacy code --- catalog/jobs/discover.py | 8 ++++--- mastodon/__init__.py | 1 - mastodon/decorators.py | 27 ------------------------ users/templates/users/announcements.html | 2 +- 4 files changed, 6 insertions(+), 32 deletions(-) delete mode 100644 mastodon/decorators.py diff --git a/catalog/jobs/discover.py b/catalog/jobs/discover.py index 606c858f..9c552ec8 100644 --- a/catalog/jobs/discover.py +++ b/catalog/jobs/discover.py @@ -147,12 +147,14 @@ class DiscoverGenerator(BaseJob): "pk", flat=True )[:20] ) + print(post_ids) if len(post_ids) < 30: post_ids |= set( - Takahe.get_popular_posts(3, 1) - .order_by("-published") - .values_list("pk", flat=True)[:2] + Comment.objects.filter(visibility=0) + .order_by("-created_time") + .values_list("posts", flat=True)[:2] ) + print(post_ids) cache.set("public_gallery", gallery_list, timeout=None) cache.set("trends_links", trends, timeout=None) cache.set("featured_collections", collection_ids, timeout=None) diff --git a/mastodon/__init__.py b/mastodon/__init__.py index 48bad832..e69de29b 100644 --- a/mastodon/__init__.py +++ b/mastodon/__init__.py @@ -1 +0,0 @@ -from .decorators import * diff --git a/mastodon/decorators.py b/mastodon/decorators.py deleted file mode 100644 index 03f6ce0f..00000000 --- a/mastodon/decorators.py +++ /dev/null @@ -1,27 +0,0 @@ -import functools - -from django.http import HttpResponse -from django.shortcuts import render -from django.utils.translation import gettext_lazy as _ -from requests.exceptions import Timeout - - -def mastodon_request_included(func): - """Handles timeout exception of requests to mastodon, returns http 500""" - - @functools.wraps(func) - def wrapper(*args, **kwargs): - try: - return func(*args, **kwargs) - except (Timeout, ConnectionError): - return render( - args[0], - "common/error.html", - {"msg": _("Timeout connecting to Fediverse.")}, - ) - - return wrapper - - -class HttpResponseInternalServerError(HttpResponse): - status_code = 500 diff --git a/users/templates/users/announcements.html b/users/templates/users/announcements.html index f328750b..cb97ab7f 100644 --- a/users/templates/users/announcements.html +++ b/users/templates/users/announcements.html @@ -46,7 +46,7 @@
{{ announcement.html | safe }}