def channel_top_list(self, count, user, server):
"""
Gets top <count> channels for a user
:param count: length of top list
:param user: the user
:param server: the server
:return: a SelectQuery with Message.channel with the top channels
"""
messages = (user.messages
.select(self.models.Message.channel)
.join(self.models.Server, on=(self.models.Server.id == self.models.Channel.server))
.switch(self.models.Message)
# peewee needs the ==
.where(self.models.Message.is_command == False,
self.models.Server.id == server)
.annotate(self.models.Channel)
.order_by(SQL('count').desc())
.limit(count))
return messages
评论列表
文章目录