Merge branch 'master' of git://git.assembla.com/fpdb

This commit is contained in:
gimick 2010-08-10 00:31:14 +01:00
commit 792e66c2b5
7 changed files with 331 additions and 19 deletions

View File

@ -2115,6 +2115,32 @@ 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
names=[]
for column in columnNames:
names.append(column[0])
data=c.fetchone()
return (names,data)
#end def getTourneyInfo
def getTourneyPlayerInfo(self, siteName, tourneyNo, playerName):
c = self.get_cursor()
c.execute(self.sql.query['getTourneyPlayerInfo'], (siteName, tourneyNo, playerName))
columnNames=c.description
names=[]
for column in columnNames:
names.append(column[0])
data=c.fetchone()
return (names,data)
#end def getTourneyPlayerInfo
#end class Database
# Class used to hold all the data needed to write a hand to the db

139
pyfpdb/GuiTourneyViewer.py Normal file
View File

@ -0,0 +1,139 @@
#!/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.entryTourney = gtk.Entry()
self.interfaceHBox.add(self.entryTourney)
self.displayButton = gtk.Button("_Display")
self.displayButton.connect('clicked', self.displayClicked)
self.interfaceHBox.add(self.displayButton)
self.entryPlayer = gtk.Entry()
self.interfaceHBox.add(self.entryPlayer)
self.playerButton = gtk.Button("Display _Player")
self.playerButton.connect('clicked', self.displayPlayerClicked)
self.interfaceHBox.add(self.playerButton)
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):
if self.prepare(10, 9):
result=self.db.getTourneyInfo(self.siteName, self.tourneyNo)
if result[1] == None:
self.table.destroy()
self.errorLabel=gtk.Label("Tournament not found - please ensure you imported it and selected the correct site")
self.mainVBox.add(self.errorLabel)
else:
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 displayPlayerClicked(self, widget, data=None):
if self.prepare(4, 5):
result=self.db.getTourneyPlayerInfo(self.siteName, self.tourneyNo, self.playerName)
if result[1] == None:
self.table.destroy()
self.errorLabel=gtk.Label("Player or tourney not found - please ensure you imported it and selected the correct site")
self.mainVBox.add(self.errorLabel)
else:
x=0
y=0
for i in range(1,len(result[0])):
if y==5:
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 displayPlayerClicked
def get_vbox(self):
"""returns the vbox of this thread"""
return self.mainVBox
#end def get_vbox
def prepare(self, columns, rows):
try: self.errorLabel.destroy()
except: pass
try:
self.tourneyNo=int(self.entryTourney.get_text())
except ValueError:
self.errorLabel=gtk.Label("invalid entry in tourney number - must enter numbers only")
self.mainVBox.add(self.errorLabel)
return False
self.siteName=self.siteBox.get_active_text()
self.playerName=self.entryPlayer.get_text()
self.table.destroy()
self.table=gtk.Table(columns=columns, rows=rows)
self.mainVBox.add(self.table)
return True
#end def readInfo
#end class GuiTourneyViewer

View File

@ -1336,8 +1336,6 @@ class Sql:
and (p.siteId = %s or %s = -1)
"""
self.query['getSiteId'] = """SELECT id from Sites where name = %s"""
self.query['get_stats_from_hand'] = """
SELECT hc.playerId AS player_id,
hp.seatNo AS seat,
@ -2010,8 +2008,6 @@ class Sql:
self.query['getPlayerIdBySite'] = """SELECT id from Players where name = %s AND siteId = %s"""
# used in *Filters:
self.query['getSiteId'] = """SELECT id from Sites where name = %s"""
self.query['getGames'] = """SELECT DISTINCT category from Gametypes"""
#self.query['getLimits'] = already defined further up
self.query['getLimits2'] = """SELECT DISTINCT type, limitType, bigBlind
from Gametypes
@ -2992,7 +2988,6 @@ class Sql:
,playerId
,activeSeats
,position
,tourneyTypeId
,styleKey
,HDs
,wonWhenSeenStreet1
@ -3082,7 +3077,6 @@ class Sql:
when hp.position = '9' then 'E'
else 'E'
end AS hc_position
,t.tourneyTypeId
,date_format(h.startTime, 'd%y%m%d')
,count(1)
,sum(wonWhenSeenStreet1)
@ -3156,14 +3150,11 @@ class Sql:
,sum(hp.street4Raises)
FROM HandsPlayers hp
INNER JOIN Hands h ON (h.id = hp.handId)
INNER JOIN TourneysPlayers tp ON (tp.id = hp.tourneysPlayersId)
INNER JOIN Tourneys t ON (t.id = tp.tourneyId)
<where_clause>
GROUP BY h.gametypeId
,hp.playerId
,h.seats
,hc_position
,t.tourneyTypeId
,date_format(h.startTime, 'd%y%m%d')
"""
elif db_server == 'postgresql':
@ -3173,7 +3164,6 @@ class Sql:
,playerId
,activeSeats
,position
,tourneyTypeId
,styleKey
,HDs
,wonWhenSeenStreet1
@ -3263,7 +3253,6 @@ class Sql:
when hp.position = '9' then 'E'
else 'E'
end AS hc_position
,t.tourneyTypeId
,'d' || to_char(h.startTime, 'YYMMDD')
,count(1)
,sum(wonWhenSeenStreet1)
@ -3337,14 +3326,11 @@ class Sql:
,sum(CAST(hp.street4Raises as integer))
FROM HandsPlayers hp
INNER JOIN Hands h ON (h.id = hp.handId)
INNER JOIN TourneysPlayers tp ON (tp.id = hp.tourneysPlayersId)
INNER JOIN Tourneys t ON (t.id = tp.tourneyId)
<where_clause>
GROUP BY h.gametypeId
,hp.playerId
,h.seats
,hc_position
,t.tourneyTypeId
,to_char(h.startTime, 'YYMMDD')
"""
else: # assume sqlite
@ -3354,7 +3340,6 @@ class Sql:
,playerId
,activeSeats
,position
,tourneyTypeId
,styleKey
,HDs
,wonWhenSeenStreet1
@ -3444,7 +3429,6 @@ class Sql:
when hp.position = '9' then 'E'
else 'E'
end AS hc_position
,t.tourneyTypeId
,'d' || substr(strftime('%Y%m%d', h.startTime),3,7)
,count(1)
,sum(wonWhenSeenStreet1)
@ -3518,14 +3502,11 @@ class Sql:
,sum(CAST(hp.street4Raises as integer))
FROM HandsPlayers hp
INNER JOIN Hands h ON (h.id = hp.handId)
INNER JOIN TourneysPlayers tp ON (tp.id = hp.tourneysPlayersId)
INNER JOIN Tourneys t ON (t.id = tp.tourneyId)
<where_clause>
GROUP BY h.gametypeId
,hp.playerId
,h.seats
,hc_position
,t.tourneyTypeId
,'d' || substr(strftime('%Y%m%d', h.startTime),3,7)
"""
@ -3812,6 +3793,22 @@ 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['getTourneyPlayerInfo'] = """SELECT tp.*
FROM Tourneys t
INNER JOIN TourneyTypes tt ON (t.tourneyTypeId = tt.id)
INNER JOIN Sites s ON (tt.siteId = s.id)
INNER JOIN TourneysPlayers tp ON (tp.tourneyId = t.id)
INNER JOIN Players p ON (p.id = tp.playerId)
WHERE s.name=%s AND t.siteTourneyNo=%s AND p.name=%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)

View File

@ -0,0 +1,63 @@
Game #9485557849 starts.
#Game No : 9485557849
***** Hand History for Game 9485557849 *****
$0.80 USD NL Texas Hold'em - Saturday, July 31, 13:52:16 EDT 2010
Table 20BB Min Speed #1770998 (Real Money)
Seat 1 is the button
Total number of players : 4/9
Seat 3: FErki84 ( $1.64 USD )
Seat 5: Vandercasses ( $0.01 USD )
Seat 9: jeremyho888 ( $1.02 USD )
Seat 1: sergeodem ( $1.20 USD )
FErki84 posts small blind [$0.01 USD].
Vandercasses posts big blind [$0.01 USD].
** Dealing down cards **
Dealt to FErki84 [ 8h Kc ]
jeremyho888 folds
sergeodem calls [$0.02 USD]
FErki84 calls [$0.01 USD]
** Dealing Flop ** [ Td, 7c, 9h ]
FErki84 checks
sergeodem checks
** Dealing Turn ** [ 3h ]
FErki84 checks
sergeodem checks
** Dealing River ** [ Jc ]
FErki84 bets [$0.04 USD]
sergeodem folds
FErki84 shows [ 8h, Kc ]a straight, Seven to Jack.
Vandercasses doesn't show [ Ts, Jd ]two pairs, Jacks and Tens.
FErki84 wins $0.06 USD from the side pot 1 with a straight, Seven to Jack.
FErki84 wins $0.03 USD from the main pot with a straight, Seven to Jack.
Vandercasses has left the table.
Game #9498788316 starts.
#Game No : 9498788316
***** Hand History for Game 9498788316 *****
$1.60 USD NL Texas Hold'em - Wednesday, August 04, 15:02:33 EDT 2010
Table 20BB Min #1847547 (No DP) (Real Money)
Seat 2 is the button
Total number of players : 5/6
Seat 5: CepguTbIu999 ( $1.60 USD )
Seat 1: Daytona_955 ( $2.45 USD )
Seat 4: FErki84 ( $2.18 USD )
Seat 2: anjl2009 ( $2.80 USD )
Seat 3: lukeman2 ( $0.01 USD )
lukeman2 posts small blind [$0.01 USD].
FErki84 posts big blind [$0.04 USD].
** Dealing down cards **
Dealt to FErki84 [ 6s 2c ]
CepguTbIu999 folds
Daytona_955 folds
anjl2009 folds
** Dealing Flop ** [ 9d, Ah, 3h ]
** Dealing Turn ** [ Js ]
** Dealing River ** [ Kc ]
lukeman2 shows [ 5h, 5s ]a pair of Fives.
FErki84 shows [ 6s, 2c ]high card Ace.
FErki84 wins $0.03 USD from the side pot 1 with high card, Ace.
lukeman2 wins $0.02 USD from the main pot with a pair of Fives.
lukeman2 has left the table.

View File

@ -0,0 +1,41 @@
***** Hand History For Game 9423586142 *****
0.01/0.02 Texas Hold'em Game Table (NL) - Mon Jul 12 13:38:32 EDT 2010
Table 20BB Min Speed #1775757 (Real Money) -- Seat 1 is the button
Total number of players : 9/9
Seat 1: Player1 ($0.95)
Seat 2: Player2 ($0.57)
Seat 3: Player3 ($0.86)
Seat 4: Player4 ($1.71)
Seat 5: Player5 ($1.76)
Seat 6: Player6 ($0.44)
Seat 7: Player7 ($0.76)
Seat 8: Player8 ($0.68)
Seat 9: Player9 ($0.38)
Player2 posts small blind (0.01)
Player3 posts big blind (0.02)
** Dealing down cards **
Dealt to Player5 [ Tc, 9d ]
Player5 folds
Player6 calls (0.02)
Player8 folds
Player9 folds
Player1 folds
Player2 calls (0.01)
Player3 raises 0.06 to 0.08
Player6 calls (0.06)
Player2 folds
** Dealing Flop ** : [ 5s, 7h, 6h ]
Player3 bets (0.13)
Player6 folds
** Summary **
Main Pot: $0.18 Rake: $0
Board: [ 5s 7h 6h ]
Player1 balance $0.95, didn't bet (folded)
Player2 balance $0.55, lost $0.02 (folded)
Player3 balance $0.96, bet $0.21, collected $0.31, net +$0.1
Player4 balance $1.71, sits out
Player5 balance $1.76, didn't bet (folded)
Player6 balance $0.36, lost $0.08 (folded)
Player7 balance $0.76, sits out
Player8 balance $0.68, didn't bet (folded)
Player9 balance $0.38, didn't bet (folded)

View File

@ -0,0 +1,37 @@
***** Hand History For Game 9336845949 *****
30/60 Tourney Texas Hold'em Game Table (NL) (STT Tournament #52792286) - Sun Jun 13 12:21:39 EDT 2010
Table 174827 (Real Money) -- Seat 6 is the button
Total number of players : 6/6
Seat 1: Player1 (1520)
Seat 2: Player2 (1540)
Seat 3: Player3 (2120)
Seat 4: Player4 (2460)
Seat 5: Player5 (2600)
Seat 6: Player6 (1760)
Player1 posts small blind (30)
Player2 posts big blind (60)
** Dealing down cards **
Dealt to Player5 [ Jc, Js ]
Player3 folds
Player4 folds
Player6 folds
Player1 calls (210)
Player2 folds
** Dealing Flop ** : [ 4h, 7d, 5c ]
Player1 checks
Player1 calls (450)
** Dealing Turn ** : [ Kd ]
Player1 checks
Player1 calls (830)
Player1 is all-In.
** Dealing River ** : [ Jd ]
Creating Main Pot with 3100 with Player1
** Summary **
Main Pot: 3100
Board: [ 4h 7d 5c Kd Jd ]
Player1 balance 0, lost 1520 [ Ks 6c ] [ a pair of kings -- Ks,Kd,Jd,7d,6c ]
Player2 balance 1480, lost 60 (folded)
Player3 balance 2120, didn't bet (folded)
Player4 balance 2460, didn't bet (folded)
Player5 balance 4180, bet 1520, collected 3100, net +1580 [ Jc Js ] [ three of a kind, jacks -- Kd,Jc,Js,Jd,7d ]
Player6 balance 1760, didn't bet (folded)