From 6b1ae214361f533e53d8993a530e5d2b17c4f4e9 Mon Sep 17 00:00:00 2001 From: luxagraf Date: Fri, 17 Nov 2023 16:03:19 -0500 Subject: gtd: fixed some bugs in RSS updater --- app/gtd/management/commands/rss_updater.py | 6 +++++- app/gtd/models.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/gtd/management/commands/rss_updater.py b/app/gtd/management/commands/rss_updater.py index 0f3796b..2e13fc9 100644 --- a/app/gtd/management/commands/rss_updater.py +++ b/app/gtd/management/commands/rss_updater.py @@ -1,4 +1,5 @@ from django.core.management.base import BaseCommand, CommandError +from django.core.exceptions import ObjectDoesNotExist import datetime import feedparser @@ -34,10 +35,13 @@ class Command(BaseCommand): post.date_last_pub = datetime.datetime.strptime(item.published, '%a, %d %b %Y %H:%M:%S %z').date() post.post_status = PostStatus.PUBLISHED post.save() + post = WiredPost.objects.get(url=item.link) + #print(post.date_last_pub) self.stdout.write( self.style.SUCCESS('Successfully updated post "%s"' % post.title) ) - except: + except ObjectDoesNotExist: + #print("skipping ", item.title) continue diff --git a/app/gtd/models.py b/app/gtd/models.py index f54ac3a..22af090 100644 --- a/app/gtd/models.py +++ b/app/gtd/models.py @@ -223,7 +223,7 @@ class WiredPost(models.Model): def save(self, *args, **kwargs): if self.date_last_pub: - td = timezone.localdate() - self.date_last_pub + td = datetime.date.today() - self.date_last_pub if td.days > self.update_frequency and self.post_status != 1: self.needs_update = True else: -- cgit v1.2.3-70-g09d2