Remove nb_unread/nb_messages in CapMessages

Most backends don't set it nb_messages and no application used it.
No backends set nb_unread and only one application tried to use it.

This should help avoid useless fillobj() calls in some cases.

fixes #827
This commit is contained in:
Laurent Bachelier 2012-03-22 19:25:26 +01:00 committed by Romain Bignon
commit ba5949cd22
5 changed files with 4 additions and 15 deletions

View file

@ -47,7 +47,6 @@ class HDSBackend(BaseBackend, ICapMessages):
thread = Thread(story.id)
thread.title = story.title
thread.date = story.date
thread.nb_messages = 1
yield thread
GENDERS = ['<unknown>', 'boy', 'girl', 'transexual']

View file

@ -72,7 +72,6 @@ class PhpBBBackend(BaseBackend, ICapMessages, ICapMessagesPost):
thread = Thread(url2id(link.url))
thread.title = ('%s ' % root_link.title if root_link else '') + link.title
thread.date = link.date
thread.nb_messages = link.nb_messages
thread.flags = thread.IS_DISCUSSION
yield thread

View file

@ -39,7 +39,6 @@ class Link(object):
self.url = url
self.title = u''
self.date = None
self.nb_messages = 0
class ForumPage(PhpBBPage):
def iter_links(self):
@ -63,8 +62,6 @@ class ForumPage(PhpBBPage):
continue
else:
break
# it only lists number of answers, so we add 1.
link.nb_messages = int(li.cssselect('dd.posts')[0].text.strip()) + 1
yield link
def iter_all_forums(self):

View file

@ -96,19 +96,15 @@ class MessagesListFormatter(IFormatter):
def format_dict_thread(self, item):
self.count += 1
if item['nb_unread'] and item['nb_unread'] > 0:
unread = '[N]'
else:
unread = ' '
if self.interactive:
backend = item['id'].split('@', 1)[1]
result = u'%s* (%d) %s %s (%s)%s' % (self.BOLD,
self.count, unread,
result = u'%s* (%d) %s (%s)%s' % (self.BOLD,
self.count,
item['title'], backend,
self.NC)
else:
result = u'%s* (%s) %s %s%s' % (self.BOLD, item['id'],
unread, item['title'],
result = u'%s* (%s) %s%s' % (self.BOLD, item['id'],
item['title'],
self.NC)
if item['date']:
result += u'\n %s' % item['date']

View file

@ -105,8 +105,6 @@ class Thread(CapBaseObject):
self.add_field('root', Message)
self.add_field('title', basestring)
self.add_field('date', (datetime.datetime, datetime.date))
self.add_field('nb_messages', int)
self.add_field('nb_unread', int)
self.add_field('flags', int, self.IS_THREADS)
def iter_all_messages(self):