mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Merge feeds that are found to be dupes during the exception handling manual process.
This commit is contained in:
parent
cbbe8afd58
commit
1d077bb325
2 changed files with 22 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
|||
from utils import log as logging
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.http import HttpResponseForbidden
|
||||
from apps.rss_feeds.models import Feed
|
||||
from apps.rss_feeds.models import Feed, merge_feeds
|
||||
from utils.user_functions import ajax_login_required
|
||||
from utils import json, feedfinder
|
||||
from utils.feed_functions import relative_timeuntil, relative_timesince
|
||||
|
@ -50,6 +50,7 @@ def exception_retry(request):
|
|||
def exception_change_feed_address(request):
|
||||
feed_id = request.POST['feed_id']
|
||||
feed = get_object_or_404(Feed, pk=feed_id)
|
||||
feed_address = request.POST['feed_address']
|
||||
|
||||
if not feed.has_exception:
|
||||
logging.info(" ***********> [%s] Incorrect feed address change: %s" % (request.user, feed))
|
||||
|
@ -58,8 +59,15 @@ def exception_change_feed_address(request):
|
|||
feed.has_exception = False
|
||||
feed.active = True
|
||||
feed.fetched_once = False
|
||||
feed.feed_address = request.POST['feed_address']
|
||||
feed.save()
|
||||
feed.feed_address = feed_address
|
||||
try:
|
||||
feed.save()
|
||||
except:
|
||||
original_feed = Feed.objects.get(feed_address=feed_address)
|
||||
original_feed.has_exception = False
|
||||
original_feed.active = True
|
||||
original_feed.save()
|
||||
merge_feeds(original_feed.pk, feed.pk)
|
||||
|
||||
return {'code': 1}
|
||||
|
||||
|
@ -73,6 +81,7 @@ def exception_change_feed_link(request):
|
|||
|
||||
if not feed.has_exception:
|
||||
logging.info(" ***********> [%s] Incorrect feed address change: %s" % (request.user, feed))
|
||||
# This Forbidden-403 throws an error, which sounds pretty good to me right now
|
||||
return HttpResponseForbidden()
|
||||
|
||||
feed_address = feedfinder.feed(feed_link)
|
||||
|
@ -83,7 +92,14 @@ def exception_change_feed_link(request):
|
|||
feed.fetched_once = False
|
||||
feed.feed_link = feed_link
|
||||
feed.feed_address = feed_address
|
||||
feed.save()
|
||||
try:
|
||||
feed.save()
|
||||
except:
|
||||
original_feed = Feed.objects.get(feed_address=feed_address)
|
||||
original_feed.has_exception = False
|
||||
original_feed.active = True
|
||||
original_feed.save()
|
||||
merge_feeds(original_feed.pk, feed.pk)
|
||||
|
||||
return {'code': code}
|
||||
|
||||
|
|
|
@ -11,11 +11,13 @@ graph_config = {
|
|||
'feeds.label': 'feeds',
|
||||
'subscriptions.label': 'subscriptions',
|
||||
'update_queue.label': 'update_queue',
|
||||
'exception_feeds.label': 'exception_feeds',
|
||||
}
|
||||
|
||||
metrics = {
|
||||
'feeds': Feed.objects.count(),
|
||||
'subscriptions': UserSubscription.objects.count(),
|
||||
'exception_feeds': Feed.objects.count(has_exception=True).count(),
|
||||
'update_queue': Feed.objects.filter(next_scheduled_update__lte=datetime.datetime.now()).count(),
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue