implement simple DB stats - Hand and tourney count

This commit is contained in:
steffen123 2010-07-10 02:07:47 +02:00
parent 00e156beba
commit 4c00ef19cc
3 changed files with 18 additions and 2 deletions

View File

@ -553,6 +553,18 @@ class Database:
c.execute(self.sql.query['get_hand_info'], new_hand_id)
return c.fetchall()
def getHandCount(self):
c = self.connection.cursor()
c.execute(self.sql.query['getHandCount'])
return c.fetchone()[0]
#end def getHandCount
def getTourneyCount(self):
c = self.connection.cursor()
c.execute(self.sql.query['getTourneyCount'])
return c.fetchone()[0]
#end def getTourneyCount
def get_actual_seat(self, hand_id, name):
c = self.connection.cursor()
c.execute(self.sql.query['get_actual_seat'], (hand_id, name))

View File

@ -3834,6 +3834,9 @@ class Sql:
%s
)"""
self.query['getHandCount'] = "SELECT COUNT(id) FROM Hands"
self.query['getTourneyCount'] = "SELECT COUNT(id) FROM Tourneys"
if db_server == 'mysql':
self.query['placeholder'] = u'%s'
elif db_server == 'postgresql':

View File

@ -323,7 +323,8 @@ class fpdb:
+ "other windows have been opened. Re-start fpdb to use this option.")
def dia_database_stats(self, widget, data=None):
self.warning_box("Unimplemented: Database Stats")
self.warning_box(str="Number of hands: "+str(self.db.getHandCount())+"\nNumber of tourneys: "+str(self.db.getTourneyCount()), diatitle="Database Statistics")
#end def dia_database_stats
# def dia_get_db_root_credentials(self):
# """obtains db root credentials from user"""
@ -685,7 +686,7 @@ class fpdb:
('createtabs', None, 'Create or Recreate _Tables', None, 'Create or Recreate Tables ', self.dia_recreate_tables),
('rebuildhudcache', None, 'Rebuild HUD Cache', None, 'Rebuild HUD Cache', self.dia_recreate_hudcache),
('rebuildindexes', None, 'Rebuild DB Indexes', None, 'Rebuild DB Indexes', self.dia_rebuild_indexes),
('stats', None, '_Statistics (todo)', None, 'View Database Statistics', self.dia_database_stats),
('stats', None, '_Statistics', None, 'View Database Statistics', self.dia_database_stats),
('help', None, '_Help'),
('Logs', None, '_Log Messages', None, 'Log and Debug Messages', self.dia_logs),
('About', None, 'A_bout', None, 'About the program', self.dia_about),