utvidet statistikk i dibblermenyen, samt at 0 i dibblermenyen gir alternativ 10. Jeg legger også med en logfil for de som vil teste statistikken uten å koble opp til databasen

This commit is contained in:
Trygve Magnus Ræder 2011-06-22 18:39:49 +00:00
parent 2112bc5df9
commit 76ca1e8788
2 changed files with 4510 additions and 2 deletions

4499
default.dibblerlog Normal file

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@ from sqlalchemy import desc
import re, sys, os, traceback, signal, readline import re, sys, os, traceback, signal, readline
from helpers import * from helpers import *
import random import random
from statistikkHelpers import statisticsTextOnly
random.seed() random.seed()
exit_commands = ['exit', 'abort', 'quit', 'bye', 'eat flaming death', 'q'] exit_commands = ['exit', 'abort', 'quit', 'bye', 'eat flaming death', 'q']
@ -185,6 +185,8 @@ class Menu():
else: else:
if result.isdigit(): if result.isdigit():
choice = int(result) choice = int(result)
if (choice == 0 and 10 <= number_of_choices):
return 10
if (choice > 0 and choice <= number_of_choices): if (choice > 0 and choice <= number_of_choices):
return choice return choice
if not self.special_input_choice(result): if not self.special_input_choice(result):
@ -1134,6 +1136,12 @@ class BalanceMenu(Menu):
text += 24*'-'+'\n' text += 24*'-'+'\n'
text += line_format % ('Total balance', total_balance) text += line_format % ('Total balance', total_balance)
less(text) less(text)
class LoggedStatisticsMenu(Menu):
def __init__(self):
Menu.__init__(self, 'Statistics from log', uses_db=True)
def _execute(self):
statisticsTextOnly()
def restart(): def restart():
# Does not work if the script is not executable, or if it was # Does not work if the script is not executable, or if it was
# started by searching $PATH. # started by searching $PATH.
@ -1280,7 +1288,8 @@ main = MainMenu('Dibbler main menu',
Menu('Statistics', Menu('Statistics',
items=[ProductPopularityMenu(), items=[ProductPopularityMenu(),
ProductRevenueMenu(), ProductRevenueMenu(),
BalanceMenu()]), BalanceMenu(),
LoggedStatisticsMenu()]),
FAQMenu() FAQMenu()
], ],
exit_msg='happy happy joy joy', exit_msg='happy happy joy joy',