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 = ?
|
newsgroup_id = ?
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cr = self.db.execute(sql, (newsgroup.id))
|
cr = self.db.execute(sql, (newsgroup.id,))
|
||||||
row = cr.fetchone()
|
row = cr.fetchone()
|
||||||
|
|
||||||
return "%d %d %d %s" % (
|
return {
|
||||||
row[0],
|
'count': row[0],
|
||||||
row[1],
|
'min': row[1],
|
||||||
row[2],
|
'max': row[2],
|
||||||
newsgroup.name
|
'name': newsgroup.name,
|
||||||
)
|
'perms': 'n'
|
||||||
|
}
|
||||||
|
|
||||||
def _cmd_listgroup(self, *args):
|
def _cmd_listgroup(self, *args):
|
||||||
newsgroup = self.newsgroup
|
newsgroup = self.newsgroup
|
||||||
|
@ -263,40 +264,27 @@ class Session():
|
||||||
summary = self._newsgroup_summary(newsgroup)
|
summary = self._newsgroup_summary(newsgroup)
|
||||||
cr = self.db.execute(sql, (newsgroup.id))
|
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():
|
for message in cr.each():
|
||||||
self.print(str(message.id))
|
self.print(str(message.id))
|
||||||
|
|
||||||
return self.end()
|
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):
|
def print_newsgroup(self, newsgroup: Newsgroup):
|
||||||
summary = self._newsgroup_summary(newsgroup)
|
summary = self._newsgroup_summary(newsgroup)
|
||||||
|
|
||||||
return self.print("%s %d %d %s" % (
|
return self.print("%s %d %d %s" % (
|
||||||
newsgroup.name,
|
summary['name'],
|
||||||
summary['low'],
|
summary['min'],
|
||||||
summary['high'],
|
summary['max'],
|
||||||
summary['perms']
|
summary['perms']
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue