Merge branch 'master' of git://git.assembla.com/fpdboz
This commit is contained in:
commit
28e5a05037
|
@ -635,6 +635,11 @@ class FpdbSQLQueries:
|
||||||
elif(self.dbname == 'SQLite'):
|
elif(self.dbname == 'SQLite'):
|
||||||
self.query['getPlayerId'] = """SELECT id from Players where name = %s"""
|
self.query['getPlayerId'] = """SELECT id from Players where name = %s"""
|
||||||
|
|
||||||
|
if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'):
|
||||||
|
self.query['getSiteId'] = """SELECT id from Sites where name = %s"""
|
||||||
|
elif(self.dbname == 'SQLite'):
|
||||||
|
self.query['getSiteId'] = """SELECT id from Sites where name = %s"""
|
||||||
|
|
||||||
if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'):
|
if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'):
|
||||||
self.query['getRingProfitAllHandsPlayerIdSite'] = """
|
self.query['getRingProfitAllHandsPlayerIdSite'] = """
|
||||||
SELECT hp.handId, hp.winnings, coalesce(hp.ante,0) + SUM(ha.amount)
|
SELECT hp.handId, hp.winnings, coalesce(hp.ante,0) + SUM(ha.amount)
|
||||||
|
@ -643,8 +648,10 @@ class FpdbSQLQueries:
|
||||||
INNER JOIN Players pl ON hp.playerId = pl.id
|
INNER JOIN Players pl ON hp.playerId = pl.id
|
||||||
INNER JOIN Hands h ON h.id = hp.handId
|
INNER JOIN Hands h ON h.id = hp.handId
|
||||||
INNER JOIN HandsActions ha ON ha.handPlayerId = hp.id
|
INNER JOIN HandsActions ha ON ha.handPlayerId = hp.id
|
||||||
WHERE pl.name = %s
|
where pl.id in <player_test>
|
||||||
AND pl.siteId = %s
|
AND pl.siteId in <site_test>
|
||||||
|
AND h.handStart > '<startdate_test>'
|
||||||
|
AND h.handStart < '<enddate_test>'
|
||||||
AND hp.tourneysPlayersId IS NULL
|
AND hp.tourneysPlayersId IS NULL
|
||||||
GROUP BY hp.handId, hp.winnings, h.handStart, hp.ante
|
GROUP BY hp.handId, hp.winnings, h.handStart, hp.ante
|
||||||
ORDER BY h.handStart"""
|
ORDER BY h.handStart"""
|
||||||
|
@ -656,8 +663,10 @@ class FpdbSQLQueries:
|
||||||
INNER JOIN Players pl ON hp.playerId = pl.id
|
INNER JOIN Players pl ON hp.playerId = pl.id
|
||||||
INNER JOIN Hands h ON h.id = hp.handId
|
INNER JOIN Hands h ON h.id = hp.handId
|
||||||
INNER JOIN HandsActions ha ON ha.handPlayerId = hp.id
|
INNER JOIN HandsActions ha ON ha.handPlayerId = hp.id
|
||||||
WHERE pl.name = %s
|
where pl.id in <player_test>
|
||||||
AND pl.siteId = %s
|
AND pl.siteId in <site_test>
|
||||||
|
AND h.handStart > '<startdate_test>'
|
||||||
|
AND h.handStart < '<enddate_test>'
|
||||||
AND hp.tourneysPlayersId IS NULL
|
AND hp.tourneysPlayersId IS NULL
|
||||||
GROUP BY hp.handId, hp.winnings, h.handStart
|
GROUP BY hp.handId, hp.winnings, h.handStart
|
||||||
ORDER BY h.handStart"""
|
ORDER BY h.handStart"""
|
||||||
|
|
|
@ -50,22 +50,27 @@ class GuiGraphViewer (threading.Thread):
|
||||||
try: self.canvas.destroy()
|
try: self.canvas.destroy()
|
||||||
except AttributeError: pass
|
except AttributeError: pass
|
||||||
|
|
||||||
# Whaich sites are selected?
|
sitenos = []
|
||||||
# TODO:
|
playerids = []
|
||||||
# What hero names for the selected site?
|
|
||||||
# TODO:
|
|
||||||
|
|
||||||
name = self.heroes[self.sites]
|
# Which sites are selected?
|
||||||
|
for site in self.sites:
|
||||||
|
if self.sites[site] == True:
|
||||||
|
sitenos.append(self.siteid[site])
|
||||||
|
self.cursor.execute(self.sql.query['getPlayerId'], (self.heroes[site],))
|
||||||
|
result = self.db.cursor.fetchall()
|
||||||
|
if len(result) == 1:
|
||||||
|
playerids.append(result[0][0])
|
||||||
|
|
||||||
if self.sites == "PokerStars":
|
if sitenos == []:
|
||||||
site=2
|
#Should probably pop up here.
|
||||||
sitename="PokerStars: "
|
print "No sites selected - defaulting to PokerStars"
|
||||||
elif self.sites=="Full Tilt":
|
sitenos = [2]
|
||||||
site=1
|
|
||||||
sitename="Full Tilt: "
|
|
||||||
else:
|
if playerids == []:
|
||||||
print "invalid text in site selection in graph, defaulting to PS"
|
print "No player ids found"
|
||||||
site=2
|
return
|
||||||
|
|
||||||
self.fig = Figure(figsize=(5,4), dpi=100)
|
self.fig = Figure(figsize=(5,4), dpi=100)
|
||||||
|
|
||||||
|
@ -74,7 +79,7 @@ class GuiGraphViewer (threading.Thread):
|
||||||
|
|
||||||
#Get graph data from DB
|
#Get graph data from DB
|
||||||
starttime = time()
|
starttime = time()
|
||||||
line = self.getRingProfitGraph(name, site)
|
line = self.getRingProfitGraph(playerids, sitenos)
|
||||||
print "Graph generated in: %s" %(time() - starttime)
|
print "Graph generated in: %s" %(time() - starttime)
|
||||||
|
|
||||||
self.ax.set_title("Profit graph for ring games")
|
self.ax.set_title("Profit graph for ring games")
|
||||||
|
@ -87,7 +92,8 @@ class GuiGraphViewer (threading.Thread):
|
||||||
#TODO: Do something useful like alert user
|
#TODO: Do something useful like alert user
|
||||||
print "No hands returned by graph query"
|
print "No hands returned by graph query"
|
||||||
else:
|
else:
|
||||||
text = "All Hands, " + sitename + str(name) + "\nProfit: $" + str(line[-1]) + "\nTotal Hands: " + str(len(line))
|
# text = "All Hands, " + sitename + str(name) + "\nProfit: $" + str(line[-1]) + "\nTotal Hands: " + str(len(line))
|
||||||
|
text = "All Hands, " + "\nProfit: $" + str(line[-1]) + "\nTotal Hands: " + str(len(line))
|
||||||
|
|
||||||
self.ax.annotate(text,
|
self.ax.annotate(text,
|
||||||
xy=(10, -10),
|
xy=(10, -10),
|
||||||
|
@ -103,8 +109,34 @@ class GuiGraphViewer (threading.Thread):
|
||||||
self.canvas.show()
|
self.canvas.show()
|
||||||
#end of def showClicked
|
#end of def showClicked
|
||||||
|
|
||||||
def getRingProfitGraph(self, name, site):
|
def getRingProfitGraph(self, names, sites):
|
||||||
self.cursor.execute(self.sql.query['getRingProfitAllHandsPlayerIdSite'], (name, site))
|
tmp = self.sql.query['getRingProfitAllHandsPlayerIdSite']
|
||||||
|
# print "DEBUG: getRingProfitGraph"
|
||||||
|
start_date, end_date = self.__get_dates()
|
||||||
|
|
||||||
|
if start_date == '':
|
||||||
|
start_date = '1970-01-01'
|
||||||
|
if end_date == '':
|
||||||
|
end_date = '2020-12-12'
|
||||||
|
|
||||||
|
#Buggered if I can find a way to do this 'nicely' take a list of intergers and longs
|
||||||
|
# and turn it into a tuple readale by sql.
|
||||||
|
# [5L] into (5) not (5,) and [5L, 2829L] into (5, 2829)
|
||||||
|
nametest = str(tuple(names))
|
||||||
|
sitetest = str(tuple(sites))
|
||||||
|
nametest = nametest.replace("L", "")
|
||||||
|
nametest = nametest.replace(",)",")")
|
||||||
|
sitetest = sitetest.replace(",)",")")
|
||||||
|
|
||||||
|
#Must be a nicer way to deal with tuples of size 1 ie. (2,) - which makes sql barf
|
||||||
|
tmp = tmp.replace("<player_test>", nametest)
|
||||||
|
tmp = tmp.replace("<site_test>", sitetest)
|
||||||
|
tmp = tmp.replace("<startdate_test>", start_date)
|
||||||
|
tmp = tmp.replace("<enddate_test>", end_date)
|
||||||
|
|
||||||
|
# print "DEBUG: sql query:"
|
||||||
|
# print tmp
|
||||||
|
self.cursor.execute(tmp)
|
||||||
#returns (HandId,Winnings,Costs,Profit)
|
#returns (HandId,Winnings,Costs,Profit)
|
||||||
winnings = self.db.cursor.fetchall()
|
winnings = self.db.cursor.fetchall()
|
||||||
|
|
||||||
|
@ -125,7 +157,6 @@ class GuiGraphViewer (threading.Thread):
|
||||||
pname.set_text(player)
|
pname.set_text(player)
|
||||||
pname.set_width_chars(20)
|
pname.set_width_chars(20)
|
||||||
hbox.pack_start(pname, False, True, 0)
|
hbox.pack_start(pname, False, True, 0)
|
||||||
#TODO: Need to connect a callback here
|
|
||||||
pname.connect("changed", self.__set_hero_name, site)
|
pname.connect("changed", self.__set_hero_name, site)
|
||||||
#TODO: Look at GtkCompletion - to fill out usernames
|
#TODO: Look at GtkCompletion - to fill out usernames
|
||||||
pname.show()
|
pname.show()
|
||||||
|
@ -134,7 +165,7 @@ class GuiGraphViewer (threading.Thread):
|
||||||
|
|
||||||
def __set_hero_name(self, w, site):
|
def __set_hero_name(self, w, site):
|
||||||
self.heroes[site] = w.get_text()
|
self.heroes[site] = w.get_text()
|
||||||
print "DEBUG: settings heroes[%s]: %s"%(site, self.heroes[site])
|
# print "DEBUG: settings heroes[%s]: %s"%(site, self.heroes[site])
|
||||||
|
|
||||||
def createSiteLine(self, hbox, site):
|
def createSiteLine(self, hbox, site):
|
||||||
cb = gtk.CheckButton(site)
|
cb = gtk.CheckButton(site)
|
||||||
|
@ -144,8 +175,9 @@ class GuiGraphViewer (threading.Thread):
|
||||||
|
|
||||||
def __set_site_select(self, w, site):
|
def __set_site_select(self, w, site):
|
||||||
# This doesn't behave as intended - self.site only allows 1 site for the moment.
|
# This doesn't behave as intended - self.site only allows 1 site for the moment.
|
||||||
self.sites = site
|
print w.get_active()
|
||||||
print "self.sites set to %s" %(self.sites)
|
self.sites[site] = w.get_active()
|
||||||
|
print "self.sites[%s] set to %s" %(site, self.sites[site])
|
||||||
|
|
||||||
def fillPlayerFrame(self, vbox):
|
def fillPlayerFrame(self, vbox):
|
||||||
for site in self.conf.supported_sites.keys():
|
for site in self.conf.supported_sites.keys():
|
||||||
|
@ -162,6 +194,13 @@ class GuiGraphViewer (threading.Thread):
|
||||||
vbox.pack_start(hbox, False, True, 0)
|
vbox.pack_start(hbox, False, True, 0)
|
||||||
hbox.show()
|
hbox.show()
|
||||||
self.createSiteLine(hbox, site)
|
self.createSiteLine(hbox, site)
|
||||||
|
#Get db site id for filtering later
|
||||||
|
self.cursor.execute(self.sql.query['getSiteId'], (site,))
|
||||||
|
result = self.db.cursor.fetchall()
|
||||||
|
if len(result) == 1:
|
||||||
|
self.siteid[site] = result[0][0]
|
||||||
|
else:
|
||||||
|
print "Either 0 or more than one site matched - EEK"
|
||||||
|
|
||||||
def fillDateFrame(self, vbox):
|
def fillDateFrame(self, vbox):
|
||||||
# Hat tip to Mika Bostrom - calendar code comes from PokerStats
|
# Hat tip to Mika Bostrom - calendar code comes from PokerStats
|
||||||
|
@ -261,7 +300,8 @@ class GuiGraphViewer (threading.Thread):
|
||||||
self.sql=querylist
|
self.sql=querylist
|
||||||
self.conf = config
|
self.conf = config
|
||||||
|
|
||||||
self.sites = "PokerStars"
|
self.sites = {}
|
||||||
|
self.siteid = {}
|
||||||
self.heroes = {}
|
self.heroes = {}
|
||||||
|
|
||||||
# For use in date ranges.
|
# For use in date ranges.
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
<location seat="2" x="10" y="288"> </location>
|
<location seat="2" x="10" y="288"> </location>
|
||||||
</layout>
|
</layout>
|
||||||
</site>
|
</site>
|
||||||
<site enabled="True" site_name="Full Tilt" table_finder="FullTiltPoker.exe" screen_name="ENTER HERO NAME" site_path="~/.wine/drive_c/Program Files/Full Tilt Poker/" HH_path="~/.wine/drive_c/Program Files/Full Tilt Poker/HandHistory/abc/" decoder="fulltilt_decode_table" converter="passthrough" supported_games="holdem,razz,omahahi,omahahilo,studhi,studhilo">
|
<site enabled="True" site_name="Full Tilt Poker" table_finder="FullTiltPoker.exe" screen_name="ENTER HERO NAME" site_path="~/.wine/drive_c/Program Files/Full Tilt Poker/" HH_path="~/.wine/drive_c/Program Files/Full Tilt Poker/HandHistory/abc/" decoder="fulltilt_decode_table" converter="passthrough" supported_games="holdem,razz,omahahi,omahahilo,studhi,studhilo">
|
||||||
<layout fav_seat="0" height="547" max="8" width="794">
|
<layout fav_seat="0" height="547" max="8" width="794">
|
||||||
<location seat="1" x="640" y="64"> </location>
|
<location seat="1" x="640" y="64"> </location>
|
||||||
<location seat="2" x="650" y="230"> </location>
|
<location seat="2" x="650" y="230"> </location>
|
||||||
|
|
|
@ -177,6 +177,7 @@ class fpdb_db:
|
||||||
self.cursor.execute("INSERT INTO Settings VALUES (118);")
|
self.cursor.execute("INSERT INTO Settings VALUES (118);")
|
||||||
self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, 'Full Tilt Poker', 'USD');")
|
self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, 'Full Tilt Poker', 'USD');")
|
||||||
self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, 'PokerStars', 'USD');")
|
self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, 'PokerStars', 'USD');")
|
||||||
|
self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, 'Everleaf', 'USD');")
|
||||||
self.cursor.execute("INSERT INTO TourneyTypes VALUES (DEFAULT, 1, 0, 0, 0, False);")
|
self.cursor.execute("INSERT INTO TourneyTypes VALUES (DEFAULT, 1, 0, 0, 0, False);")
|
||||||
#end def fillDefaultData
|
#end def fillDefaultData
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user