Save feed status directly instead of at end of processing
authorMagnus Hagander <magnus@hagander.net>
Wed, 10 Feb 2016 21:09:53 +0000 (22:09 +0100)
committerMagnus Hagander <magnus@hagander.net>
Wed, 10 Feb 2016 21:09:53 +0000 (22:09 +0100)
Since processing can take a long time with slow blogs, store the
date before that happens.

This will prevent from conflicting with the web UI and overwriting
the settings from that one.

hamnadmin/hamnadmin/register/management/commands/aggregate_feeds.py
hamnadmin/hamnadmin/util/aggregate.py

index cea8d27ec65741c9847a15cda1b426b5a39f3194..007bf63db2df8aa8a2ecd1ee49251e8f6555b5c6 100644 (file)
@@ -86,8 +86,6 @@ class Command(BaseCommand):
                                                                entries += 1
                                                                titles.append(entry.title)
                                                                total_entries += 1
-                                               # Save an update to when the feed was last scanned
-                                               feed.save()
 
                                                if entries > 0 and feed.approved:
                                                        # Email a notification that they were picked up
index a6610db29302da3df6cd5a8af35d4feab53c2929..5e21f919ba4cf0ff89dc1950dc4c7b52b552f6d8 100644 (file)
@@ -105,11 +105,13 @@ class FeedFetcher(object):
                                d = datetime.datetime.now()
 
                        self.feed.lastget = d
+                       self.feed.save()
                else:
                        # We didn't get a Last-Modified time, so set it to the entry date
                        # for the latest entry in this feed.
                        if self.newest_entry_date:
                                self.feed.lastget = self.newest_entry_date
+                               self.feed.save()
 
        def matches_filter(self, entry):
                # For now, we only match against self.feed.authorfilter. In the future,