Fixed #862667 - floats in 'karma most' output, also made the number of items

shown with 'karma most' into a configurable and fixed a typo in one of the
other configurable descriptions
This commit is contained in:
Daniel DiPaolo 2003-12-19 03:13:17 +00:00
parent 1474c16a5f
commit 29cdcfb437
2 changed files with 23 additions and 4 deletions

View File

@ -74,7 +74,10 @@ class Karma(callbacks.PrivmsgCommandAndRegexp,
something's karma is increased or decreased."""),
('karma-ranking-display', configurable.IntType, 3,
"""Determines how many highest/lowest karma things are shown when
karms is called with no arguments."""),]
karma is called with no arguments."""),
('karma-most-display', configurable.IntType, 25,
"""Determines how many karma things are shown when karma most is
called."""),]
)
def __init__(self):
callbacks.PrivmsgCommandAndRegexp.__init__(self)
@ -203,12 +206,13 @@ class Karma(callbacks.PrivmsgCommandAndRegexp,
self.log.error('Impossible condition in most: kind=%s' % kind)
irc.error(msg, conf.replyPossibleBug)
return
sql = "SELECT name, %s FROM karma ORDER BY %s DESC LIMIT 50" % \
(orderby, orderby)
sql = "SELECT name, %s FROM karma ORDER BY %s DESC LIMIT %s" % \
(orderby, orderby,
self.configurables.get('karma-most-display', channel))
db = self.getDb(channel)
cursor = db.cursor()
cursor.execute(sql)
L = ['%s: %s' % (name, i) for (name, i) in cursor.fetchall()]
L = ['%s: %s' % (name, int(i)) for (name, i) in cursor.fetchall()]
if L:
irc.reply(msg, utils.commaAndify(L))
else:

View File

@ -126,6 +126,21 @@ if sqlite is not None:
self.assertNoResponse('foo++', 2)
self.assertNotError('karma config karma-response on')
self.assertNotError('foo++')
def testKarmaMostDisplayConfigurable(self):
self.assertNoResponse('foo++', 1)
self.assertNoResponse('foo++', 1)
self.assertNoResponse('bar++', 1)
self.assertNoResponse('bar--', 1)
self.assertNoResponse('bar--', 1)
self.assertNoResponse('foo--', 1)
self.assertNoResponse('foo--', 1)
self.assertNoResponse('foo--', 1)
self.assertNoResponse('foo--', 1)
self.assertNotError('karma config karma-most-display 1')
self.assertRegexp('karma most active', '(?!bar)')
self.assertNotError('karma config karma-most-display 25')
self.assertRegexp('karma most active', 'bar')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: