Closed #860139 - including wordstat count in stat output as well as rank. Also

made it so that if your name already appears in the top N results that it
doesn't append that rank stuff.
This commit is contained in:
Daniel DiPaolo 2003-12-15 12:39:38 +00:00
parent 00028614c5
commit 35ecd7bd98
2 changed files with 16 additions and 6 deletions

View File

@ -604,15 +604,22 @@ class ChannelDB(plugins.ChannelDBHandler,
try:
id = ircdb.users.getUserId(msg.prefix)
rank = 1
for (_, userId) in results:
s = "" # Don't say anything if they show in the output
# already
seenUser = False
for (count, userId) in results:
if userId == id:
s = 'You are ranked %s out of %s.' % \
(rank, utils.nItems(ers, len(results)))
break
seenUser = True
if rank > numResultsShown:
s = 'You are ranked %s out of %s with %s.' % \
(rank, utils.nItems(ers, len(results)),
utils.nItems(repr(word), count))
break
else:
rank += 1
else:
s = 'You have not said %r' % word
if not seenUser:
s = 'You have not said %r' % word
ret = '%s %s. %s' % (ret, utils.commaAndify(L), s)
except KeyError:
ret = '%s %s.' % (ret, utils.commaAndify(L))

View File

@ -135,8 +135,11 @@ if sqlite is not None:
'3.*%s: 10.*%s: 5.*foo: 3' %
(userNick2, userNick1))
# Check for the extra-swanky stuff too
# (note: to do so we must make sure they don't appear in the list,
# so we'll tweak the config)
self.assertNotError('channeldb config wordstats-top-n 2')
self.assertRegexp('wordstats lol',
'total.*19 \'lol\'s.*%s: 10.*%s: 5.*foo: 4.*'
'total.*19 \'lol\'s.*%s: 10.*%s: 5.*'
'ranked 3 out of 3 \'lol\'ers' % \
(userNick2, userNick1))