Make !gstats show totals for all game modes by default
This commit is contained in:
parent
810433b656
commit
e0bf47c182
36
src/db.py
36
src/db.py
@ -394,21 +394,39 @@ def get_game_stats(mode, size):
|
|||||||
def get_game_totals(mode):
|
def get_game_totals(mode):
|
||||||
conn = _conn()
|
conn = _conn()
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
c.execute("SELECT COUNT(1) FROM game WHERE gamemode = ?", (mode,))
|
|
||||||
|
if mode == "all":
|
||||||
|
c.execute("SELECT COUNT(1) FROM game")
|
||||||
|
else:
|
||||||
|
c.execute("SELECT COUNT(1) FROM game WHERE gamemode = ?", (mode,))
|
||||||
|
|
||||||
total_games = c.fetchone()[0]
|
total_games = c.fetchone()[0]
|
||||||
if not total_games:
|
if not total_games:
|
||||||
return "No games have been played in the {0} game mode.".format(mode)
|
return "No games have been played in the {0} game mode.".format(mode)
|
||||||
c.execute("""SELECT
|
|
||||||
gamesize,
|
if mode == "all":
|
||||||
COUNT(1) AS games
|
c.execute("""SELECT
|
||||||
FROM game
|
gamesize,
|
||||||
WHERE gamemode = ?
|
COUNT(1) AS games
|
||||||
GROUP BY gamesize
|
FROM game
|
||||||
ORDER BY gamesize ASC""", (mode,))
|
GROUP BY gamesize
|
||||||
|
ORDER BY gamesize ASC""")
|
||||||
|
else:
|
||||||
|
c.execute("""SELECT
|
||||||
|
gamesize,
|
||||||
|
COUNT(1) AS games
|
||||||
|
FROM game
|
||||||
|
WHERE gamemode = ?
|
||||||
|
GROUP BY gamesize
|
||||||
|
ORDER BY gamesize ASC""", (mode,))
|
||||||
totals = []
|
totals = []
|
||||||
for row in c:
|
for row in c:
|
||||||
totals.append("\u0002{0}p\u0002: {1}".format(*row))
|
totals.append("\u0002{0}p\u0002: {1}".format(*row))
|
||||||
return "Total games (\u0002{0}\u0002): {1} | {2}".format(mode, total_games, ", ".join(totals))
|
|
||||||
|
if mode == "all":
|
||||||
|
return "Total games: {0} | {1}".format(total_games, ", ".join(totals))
|
||||||
|
else:
|
||||||
|
return "Total games (\u0002{0}\u0002): {1} | {2}".format(mode, total_games, ", ".join(totals))
|
||||||
|
|
||||||
def get_warning_points(acc, hostmask):
|
def get_warning_points(acc, hostmask):
|
||||||
peid, plid = _get_ids(acc, hostmask)
|
peid, plid = _get_ids(acc, hostmask)
|
||||||
|
@ -7087,13 +7087,13 @@ def game_stats(cli, nick, chan, rest):
|
|||||||
cli.notice(nick, messages["stats_wait_for_game_end"])
|
cli.notice(nick, messages["stats_wait_for_game_end"])
|
||||||
return
|
return
|
||||||
|
|
||||||
gamemode = var.CURRENT_GAMEMODE.name
|
gamemode = "all"
|
||||||
gamesize = None
|
gamesize = None
|
||||||
rest = rest.split()
|
rest = rest.split()
|
||||||
# Check for gamemode
|
# Check for gamemode
|
||||||
if len(rest) and not rest[0].isdigit():
|
if len(rest) and not rest[0].isdigit():
|
||||||
gamemode = rest[0]
|
gamemode = rest[0]
|
||||||
if gamemode not in var.GAME_MODES.keys():
|
if gamemode != "all" and gamemode not in var.GAME_MODES.keys():
|
||||||
gamemode, _ = complete_match(gamemode, var.GAME_MODES.keys())
|
gamemode, _ = complete_match(gamemode, var.GAME_MODES.keys())
|
||||||
if not gamemode:
|
if not gamemode:
|
||||||
cli.notice(nick, messages["invalid_mode_no_list"].format(rest[0]))
|
cli.notice(nick, messages["invalid_mode_no_list"].format(rest[0]))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user