mirror of
https://github.com/progval/Limnoria.git
synced 2025-05-04 09:21:07 -05:00
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:
parent
1474c16a5f
commit
29cdcfb437
@ -74,7 +74,10 @@ class Karma(callbacks.PrivmsgCommandAndRegexp,
|
|||||||
something's karma is increased or decreased."""),
|
something's karma is increased or decreased."""),
|
||||||
('karma-ranking-display', configurable.IntType, 3,
|
('karma-ranking-display', configurable.IntType, 3,
|
||||||
"""Determines how many highest/lowest karma things are shown when
|
"""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):
|
def __init__(self):
|
||||||
callbacks.PrivmsgCommandAndRegexp.__init__(self)
|
callbacks.PrivmsgCommandAndRegexp.__init__(self)
|
||||||
@ -203,12 +206,13 @@ class Karma(callbacks.PrivmsgCommandAndRegexp,
|
|||||||
self.log.error('Impossible condition in most: kind=%s' % kind)
|
self.log.error('Impossible condition in most: kind=%s' % kind)
|
||||||
irc.error(msg, conf.replyPossibleBug)
|
irc.error(msg, conf.replyPossibleBug)
|
||||||
return
|
return
|
||||||
sql = "SELECT name, %s FROM karma ORDER BY %s DESC LIMIT 50" % \
|
sql = "SELECT name, %s FROM karma ORDER BY %s DESC LIMIT %s" % \
|
||||||
(orderby, orderby)
|
(orderby, orderby,
|
||||||
|
self.configurables.get('karma-most-display', channel))
|
||||||
db = self.getDb(channel)
|
db = self.getDb(channel)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute(sql)
|
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:
|
if L:
|
||||||
irc.reply(msg, utils.commaAndify(L))
|
irc.reply(msg, utils.commaAndify(L))
|
||||||
else:
|
else:
|
||||||
|
@ -127,6 +127,21 @@ if sqlite is not None:
|
|||||||
self.assertNotError('karma config karma-response on')
|
self.assertNotError('karma config karma-response on')
|
||||||
self.assertNotError('foo++')
|
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:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user