Fix redeclaration of Session._newsgroup_summary()
This commit is contained in:
parent
d0628b9031
commit
454eb2aec9
1 changed files with 19 additions and 31 deletions
|
@ -225,15 +225,16 @@ class Session():
|
|||
newsgroup_id = ?
|
||||
"""
|
||||
|
||||
cr = self.db.execute(sql, (newsgroup.id))
|
||||
cr = self.db.execute(sql, (newsgroup.id,))
|
||||
row = cr.fetchone()
|
||||
|
||||
return "%d %d %d %s" % (
|
||||
row[0],
|
||||
row[1],
|
||||
row[2],
|
||||
newsgroup.name
|
||||
)
|
||||
return {
|
||||
'count': row[0],
|
||||
'min': row[1],
|
||||
'max': row[2],
|
||||
'name': newsgroup.name,
|
||||
'perms': 'n'
|
||||
}
|
||||
|
||||
def _cmd_listgroup(self, *args):
|
||||
newsgroup = self.newsgroup
|
||||
|
@ -263,40 +264,27 @@ class Session():
|
|||
summary = self._newsgroup_summary(newsgroup)
|
||||
cr = self.db.execute(sql, (newsgroup.id))
|
||||
|
||||
self.respond(ResponseCode.NNTP_GROUP_LISTING, summary)
|
||||
text = "%d %d %d %s" % (
|
||||
summary['count'],
|
||||
summary['min'],
|
||||
summary['max'],
|
||||
summary['name']
|
||||
)
|
||||
|
||||
self.respond(ResponseCode.NNTP_GROUP_LISTING, text)
|
||||
|
||||
for message in cr.each():
|
||||
self.print(str(message.id))
|
||||
|
||||
return self.end()
|
||||
|
||||
def _newsgroup_summary(self, newsgroup: Newsgroup):
|
||||
sql = """
|
||||
select
|
||||
min(message_id),
|
||||
max(message_id)
|
||||
from
|
||||
newsgroup_message
|
||||
where
|
||||
newsgroup_id = ?
|
||||
"""
|
||||
|
||||
cr = self.db.execute(sql, (newsgroup.id,))
|
||||
row = cr.fetchone()
|
||||
|
||||
return {
|
||||
'low': row[0],
|
||||
'high': row[1],
|
||||
'perms': 'n'
|
||||
}
|
||||
|
||||
def print_newsgroup(self, newsgroup: Newsgroup):
|
||||
summary = self._newsgroup_summary(newsgroup)
|
||||
|
||||
return self.print("%s %d %d %s" % (
|
||||
newsgroup.name,
|
||||
summary['low'],
|
||||
summary['high'],
|
||||
summary['name'],
|
||||
summary['min'],
|
||||
summary['max'],
|
||||
summary['perms']
|
||||
))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue