Commit 4425fa3f authored by Lysander Trischler's avatar Lysander Trischler

Refactor max twts limit into config file

parent 6a72e7c6
......@@ -405,6 +405,21 @@ other clients, including the reference implementation I believe.
When folding of mentions is disabled, both the nick and URL will be
presented.
``max_tweets_limit``
++++++++++++++++++++
This integer controls how many twts will be shown at most. When loading twts
from the cache this amount of most recent twts will be taken for each feed.
Finally, the overall loaded twts over all feeds will be reduced to this limit,
again, starting with the newest twts. There is no second limit to control the
overall number separately (yet). It defaults to ``2000``.
When ``tt`` starts slowly, you might reduce the number to improve the rendering
performance. If you're interested in older twts, a higher limit must be chosen.
The lower the number gets, the more likely it is to produce incomplete
conversation trees or even conversation trees with missing roots. It's a
tradeoff between performance and accuracy/completeness.
``[following]``
---------------
......
......@@ -39,7 +39,6 @@ class TwtxtManager:
self.read_twts_count = 0
self.unread_twts_count = 0
MAX_TWEETS_LIMIT = 2000
self._cache = shelve.open(self.config.cachefile)
self.own_source = twtxt.models.Source(nick=self.config.nick, url=self.config.twturl)
with open(self.config.twtfile, 'r', encoding='utf-8') as fd:
......@@ -50,7 +49,7 @@ class TwtxtManager:
for url, feed in self._cache.items():
if url == "last_update":
continue
tweets = feed['tweets'][-MAX_TWEETS_LIMIT:]
tweets = feed['tweets'][-self.config.max_tweets_limit:]
if not tweets:
continue
self.max_author_nick_width = max(self.max_author_nick_width, len(tweets[0].source.nick))
......@@ -73,7 +72,7 @@ class TwtxtManager:
for tweets in replies_by_subject.values():
tweets.sort()
all_tweets.sort()
#all_tweets = all_tweets[-MAX_TWEETS_LIMIT:]
all_tweets = all_tweets[-self.config.max_tweets_limit:]
# TODO Add cyclic dependency check!!
......@@ -289,6 +288,10 @@ class Config:
def fold_mentions(self):
return self._cfg.getboolean("twtxt", "fold_mentions", fallback=True)
@property
def max_tweets_limit(self):
return self._cfg.getint("twtxt", "max_tweets_limit", fallback=2000)
def colors(self, name):
return self._cfg.get("colors", name, fallback=None)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment