From 340a2f92a66259a56c73baf3e2737b88e6ed5b39 Mon Sep 17 00:00:00 2001 From: Corban-Lee Date: Wed, 10 Jul 2024 11:44:28 +0100 Subject: [PATCH] subscription - published threshold --- src/extensions/tasks.py | 4 ++++ src/feed.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/extensions/tasks.py b/src/extensions/tasks.py index 681ea1d..75d79f2 100644 --- a/src/extensions/tasks.py +++ b/src/extensions/tasks.py @@ -125,6 +125,10 @@ class TaskCog(commands.Cog): for item in feed.items: log.debug("processing item '%s'", item.guid) + if item.pub_date < sub.published_threshold: + log.debug("item '%s' older than subscription threshold '%s', skipping", item.pub_date, sub.published_threshold) + continue + blocked = any(self.filter_item(_filter, item) for _filter in filters) mutated_item = item.create_mutated_copy(sub.mutators) diff --git a/src/feed.py b/src/feed.py index 6709484..69d0e82 100644 --- a/src/feed.py +++ b/src/feed.py @@ -281,6 +281,7 @@ class Subscription(DjangoDataModel): mutators: dict[str, list[dict]] article_fetch_image: bool embed_colour: str + published_threshold: datetime active: bool channels_count: int @@ -292,6 +293,7 @@ class Subscription(DjangoDataModel): "title": item.pop("article_title_mutators"), "description": item.pop("article_desc_mutators") } + item["published_threshold"] = datetime.strptime(item["published_threshold"], "%Y-%m-%d") return item