samuelclay/NewsBlur — pull request #123 by tonyduckles (2013-03-28 04:26:46+00:00)
Title: Configurable trim_feed handling

(Fixes #120)

Introduce additional flags in settings.py for controlling how feed-trimming (purging old articles) behaves.

In `settings.py`, add a few new flags:
* `TRIM_STORIES` is the master enabled/disabled switch. Enabled by default.
* `TRIM_STORIES_KEEP_DAYS` is the minimum # of days to keep articles around for. I choose 180 days as the default.
* `TRIM_STORIES_KEEP_NUM` is the minimum # of articles to keep per feed. I choose 100 stories as the default.

In `apps/rss_feeds/models.py` (`trim_feed`), respect new `TRIM_STORIES*` flags. If `TRIM_STORIES` is enabled, if there are over `TRIM_STORIES_KEEP_NUM` stories in a given feed, pick a threshold-date for the purge by picking the lesser of the two dates between the date of the `TRIM_STORIES_KEEP_NUM`'th story in the feed versus the `Now`-`TRIM_STORIES_KEEP_DAYS` date. In other words, ensure that we keep at least `TRIM_STORIES_KEEP_DAYS` worth of articles and at least `TRIM_STORIES_KEEP_NUM` worth of articles.