add tourney viewer that displays info from TT and T, but not yet TP

This commit is contained in:
steffen123 2010-08-09 23:22:58 +02:00
parent 6ac8f410f6
commit c5bd036b6e
4 changed files with 116 additions and 0 deletions

View File

@ -2115,6 +2115,20 @@ class Database:
result = c.fetchall()
return result
#end def getTourneyTypesIds
def getTourneyInfo(self, siteName, tourneyNo):
c = self.get_cursor()
c.execute(self.sql.query['getTourneyInfo'], (siteName, tourneyNo))
columnNames=c.description
#print "columnNames:",columnNames
names=[]
for column in columnNames:
names.append(column[0])
data=c.fetchone()
return (names,data)
#end def getTourneyInfo
#end class Database
# Class used to hold all the data needed to write a hand to the db

View File

@ -0,0 +1,86 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#Copyright 2010 Steffen Schaumburg
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU Affero General Public License as published by
#the Free Software Foundation, version 3 of the License.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU Affero General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt.
import threading
import pygtk
pygtk.require('2.0')
import gtk
class GuiTourneyViewer (threading.Thread):
def __init__(self, config, db, sql, mainwin, debug=True):
self.db = db
self.mainVBox = gtk.VBox()
self.interfaceHBox = gtk.HBox()
self.mainVBox.pack_start(self.interfaceHBox, expand=False)
self.siteBox = gtk.combo_box_new_text()
for site in config.supported_sites:
self.siteBox.append_text(site)
self.siteBox.set_active(0)
self.interfaceHBox.add(self.siteBox)
label=gtk.Label("Enter the tourney number you want to display:")
self.interfaceHBox.add(label)
self.entryBox = gtk.Entry()
self.interfaceHBox.add(self.entryBox)
self.button = gtk.Button("_Display")
self.button.connect('clicked', self.displayClicked)
self.interfaceHBox.add(self.button)
self.table = gtk.Table(columns=10, rows=9)
self.mainVBox.add(self.table)
self.mainVBox.show_all()
#end def __init__
def displayClicked(self, widget, data=None):
tourneyNo=int(self.entryBox.get_text())
siteName=self.siteBox.get_active_text()
self.table.destroy()
self.table=gtk.Table(columns=10, rows=9)
self.mainVBox.add(self.table)
result=self.db.getTourneyInfo(siteName, tourneyNo)
x=0
y=0
for i in range(1,len(result[0])):
if y==9:
x+=2
y=0
label=gtk.Label(result[0][i])
self.table.attach(label,x,x+1,y,y+1)
if result[1][i]==None:
label=gtk.Label("N/A")
else:
label=gtk.Label(result[1][i])
self.table.attach(label,x+1,x+2,y,y+1)
y+=1
self.mainVBox.show_all()
#def displayClicked
def get_vbox(self):
"""returns the vbox of this thread"""
return self.mainVBox
#end def get_vbox
#end class GuiTourneyViewer

View File

@ -3812,6 +3812,13 @@ class Sql:
WHERE tt.siteId=%s AND t.siteTourneyNo=%s
"""
self.query['getTourneyInfo'] = """SELECT tt.*, t.*
FROM Tourneys t
INNER JOIN TourneyTypes tt ON (t.tourneyTypeId = tt.id)
INNER JOIN Sites s ON (tt.siteId = s.id)
WHERE s.name=%s AND t.siteTourneyNo=%s
"""
self.query['insertTourney'] = """INSERT INTO Tourneys
(tourneyTypeId, siteTourneyNo, entries, prizepool,
startTime, endTime, tourneyName, matrixIdProcessed,

View File

@ -106,6 +106,7 @@ import GuiBulkImport
import ImapFetcher
import GuiRingPlayerStats
import GuiTourneyPlayerStats
import GuiTourneyViewer
import GuiPositionalStats
import GuiAutoImport
import GuiGraphViewer
@ -794,6 +795,7 @@ class fpdb:
<menuitem action="graphs"/>
<menuitem action="ringplayerstats"/>
<menuitem action="tourneyplayerstats"/>
<menuitem action="tourneyviewer"/>
<menuitem action="posnstats"/>
<menuitem action="sessionstats"/>
</menu>
@ -833,6 +835,7 @@ class fpdb:
('graphs', None, '_Graphs', '<control>G', 'Graphs', self.tabGraphViewer),
('ringplayerstats', None, 'Ring _Player Stats (tabulated view)', '<control>P', 'Ring Player Stats (tabulated view)', self.tab_ring_player_stats),
('tourneyplayerstats', None, '_Tourney Player Stats (tabulated view, mysql only)', '<control>T', 'Tourney Player Stats (tabulated view, mysql only)', self.tab_tourney_player_stats),
('tourneyviewer', None, 'Tourney _Viewer', None, 'Tourney Viewer)', self.tab_tourney_viewer_stats),
('posnstats', None, 'P_ositional Stats (tabulated view)', '<control>O', 'Positional Stats (tabulated view)', self.tab_positional_stats),
('sessionstats', None, 'Session Stats', None, 'Session Stats', self.tab_session_stats),
('database', None, '_Database'),
@ -1033,6 +1036,12 @@ class fpdb:
ps_tab=new_ps_thread.get_vbox()
self.add_and_display_tab(ps_tab, "Tourney Player Stats")
def tab_tourney_viewer_stats(self, widget, data=None):
new_thread = GuiTourneyViewer.GuiTourneyViewer(self.config, self.db, self.sql, self.window)
self.threads.append(new_thread)
tab=new_thread.get_vbox()
self.add_and_display_tab(tab, "Tourney Viewer")
def tab_positional_stats(self, widget, data=None):
new_ps_thread = GuiPositionalStats.GuiPositionalStats(self.config, self.sql)
self.threads.append(new_ps_thread)