Skip to content
This repository has been archived by the owner on Sep 21, 2023. It is now read-only.

Commit

Permalink
Stop populating the queue with posts once the sub is closed (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimJentzsch authored Jun 30, 2023
1 parent 02a6d59 commit ec7bcbb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tor/helpers/threaded_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
log = logging.getLogger()
i18n = translation()

# The time when no more posts should be pulled into the queue
# 2023-07-01T00:00:00Z
END_TIME = datetime(2023, 7, 1, 0, 0, 0, 0, tzinfo=timezone.utc)


def check_domain_filter(item: Dict, cfg: Config) -> bool:
"""Validate that a given post is actually one that we can (or should) work on.
Expand Down Expand Up @@ -97,7 +101,13 @@ def parse_json_posts(posts: Dict) -> List[PostSummary]:

def is_time_to_scan(cfg: Config) -> bool:
"""Determine if it is time to scan for new submissions."""
return datetime.now(tz=timezone.utc) > cfg.last_post_scan_time + timedelta(seconds=45)
now = datetime.now(tz=timezone.utc)

# Don't put new posts into the queue when the sub is closed
if now >= END_TIME:
return False

return now > cfg.last_post_scan_time + timedelta(seconds=45)


@beeline.traced(name="threaded_check_submissions")
Expand Down

0 comments on commit ec7bcbb

Please sign in to comment.