From 7dd8b9de16ac86e7a511d33d5ecf9ca0fccf10ae Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 10 Dec 2010 22:31:12 +0800 Subject: [PATCH] Rename gameTypeId to gametypeId Go through and change all references to gameTypeId to gametypeId to make it consistent. The database field is named with the lowercase version, and MySQL is case sensitive. This may have been causing minor issues in multiple areas when attempting to join on gametype. --- pyfpdb/AlchemyMappings.py | 2 +- pyfpdb/Database.py | 2 +- pyfpdb/GuiPositionalStats.py | 4 +-- pyfpdb/GuiRingPlayerStats.py | 10 +++--- pyfpdb/GuiTourneyPlayerStats.py | 2 +- pyfpdb/Hand.py | 2 +- pyfpdb/SQL.py | 54 ++++++++++++++++----------------- 7 files changed, 38 insertions(+), 38 deletions(-) diff --git a/pyfpdb/AlchemyMappings.py b/pyfpdb/AlchemyMappings.py index 5e93a259..b5891c25 100644 --- a/pyfpdb/AlchemyMappings.py +++ b/pyfpdb/AlchemyMappings.py @@ -211,7 +211,7 @@ class HandInternal(DerivedStats): def isDuplicate(self, session): """Checks if current hand already exists in db - siteHandNo ans gameTypeId have to be setted + siteHandNo ans gametypeId have to be setted """ return session.query(HandInternal).filter_by( siteHandNo=self.siteHandNo, gametypeId=self.gametypeId).count()!=0 diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 7b6bfb4a..fa23f1cd 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -1708,7 +1708,7 @@ class Database: c.execute(q, ( p['tableName'], - p['gameTypeId'], + p['gametypeId'], p['siteHandNo'], p['tourneyId'], p['startTime'], diff --git a/pyfpdb/GuiPositionalStats.py b/pyfpdb/GuiPositionalStats.py index 2f7c36cc..06d28883 100644 --- a/pyfpdb/GuiPositionalStats.py +++ b/pyfpdb/GuiPositionalStats.py @@ -397,7 +397,7 @@ class GuiPositionalStats (threading.Thread): query = query.replace("", bigblindselect) query = query.replace("", "") query = query.replace("", "-1") - query = query.replace("", "-1") + query = query.replace("", "-1") else: if self.db.backend == self.MYSQL_INNODB: bigblindselect = """concat('$', trim(leading ' ' from @@ -416,7 +416,7 @@ class GuiPositionalStats (threading.Thread): query = query.replace("", bigblindselect) query = query.replace("", ",gt.bigBlind") query = query.replace("", "hc.gametypeId") - query = query.replace("", "h.gameTypeId") + query = query.replace("", "h.gametypeId") # Filter on dates query = query.replace("", " between '" + dates[0] + "' and '" + dates[1] + "'") diff --git a/pyfpdb/GuiRingPlayerStats.py b/pyfpdb/GuiRingPlayerStats.py index 39ea97b4..d3ba1bee 100644 --- a/pyfpdb/GuiRingPlayerStats.py +++ b/pyfpdb/GuiRingPlayerStats.py @@ -652,18 +652,18 @@ class GuiRingPlayerStats (GuiPlayerStats.GuiPlayerStats): query = query.replace("", bbtest) if holecards: # re-use level variables for hole card query - query = query.replace("", "hp.startcards") - query = query.replace("" + query = query.replace("", "hp.startcards") + query = query.replace("" , ",case when floor((hp.startcards-1)/13) >= mod((hp.startcards-1),13) then hp.startcards + 0.1 " + " else 13*mod((hp.startcards-1),13) + floor((hp.startcards-1)/13) + 1 " + " end desc ") else: - query = query.replace("", "") + query = query.replace("", "") groupLevels = "show" not in str(limits) if groupLevels: - query = query.replace("", "p.name") # need to use p.name for sqlite posn stats to work + query = query.replace("", "p.name") # need to use p.name for sqlite posn stats to work else: - query = query.replace("", "h.gameTypeId") + query = query.replace("", "h.gametypeId") # process self.detailFilters (a list of tuples) flagtest = '' diff --git a/pyfpdb/GuiTourneyPlayerStats.py b/pyfpdb/GuiTourneyPlayerStats.py index ef6c0f66..0b830547 100644 --- a/pyfpdb/GuiTourneyPlayerStats.py +++ b/pyfpdb/GuiTourneyPlayerStats.py @@ -382,7 +382,7 @@ class GuiTourneyPlayerStats (GuiPlayerStats.GuiPlayerStats): #query = query.replace("", bbtest) - #query = query.replace("", "") + #query = query.replace("", "") # process self.detailFilters (a list of tuples) flagtest = '' diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index b2e220b1..8485ca9e 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -261,7 +261,7 @@ db: a connected Database object""" if not db.isDuplicate(self.dbid_gt, hh['siteHandNo']): # Hands - Summary information of hand indexed by handId - gameinfo - hh['gameTypeId'] = self.dbid_gt + hh['gametypeId'] = self.dbid_gt # seats TINYINT NOT NULL, hh['seats'] = len(self.dbid_pids) diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index f6bb068b..83e19f13 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -1400,11 +1400,11 @@ class Sql: self.query['addTourneyIndex'] = """CREATE UNIQUE INDEX siteTourneyNo ON Tourneys (siteTourneyNo, tourneyTypeId)""" if db_server == 'mysql': - self.query['addHandsIndex'] = """ALTER TABLE Hands ADD UNIQUE INDEX siteHandNo(siteHandNo, gameTypeId)""" + self.query['addHandsIndex'] = """ALTER TABLE Hands ADD UNIQUE INDEX siteHandNo(siteHandNo, gametypeId)""" elif db_server == 'postgresql': - self.query['addHandsIndex'] = """CREATE UNIQUE INDEX siteHandNo ON Hands (siteHandNo, gameTypeId)""" + self.query['addHandsIndex'] = """CREATE UNIQUE INDEX siteHandNo ON Hands (siteHandNo, gametypeId)""" elif db_server == 'sqlite': - self.query['addHandsIndex'] = """CREATE UNIQUE INDEX siteHandNo ON Hands (siteHandNo, gameTypeId)""" + self.query['addHandsIndex'] = """CREATE UNIQUE INDEX siteHandNo ON Hands (siteHandNo, gametypeId)""" if db_server == 'mysql': self.query['addPlayersIndex'] = """ALTER TABLE Players ADD UNIQUE INDEX name(name, siteId)""" @@ -2145,7 +2145,7 @@ class Sql: if db_server == 'mysql': self.query['playerDetailedStats'] = """ - select AS hgametypeid + select AS hgametypeid , AS pname ,gt.base ,gt.category @@ -2231,7 +2231,7 @@ class Sql: ,variance(hp.totalProfit/100.0) AS variance from HandsPlayers hp inner join Hands h on (h.id = hp.handId) - inner join Gametypes gt on (gt.Id = h.gameTypeId) + inner join Gametypes gt on (gt.Id = h.gametypeId) inner join Sites s on (s.Id = gt.siteId) inner join Players p on (p.Id = hp.playerId) where hp.playerId in @@ -2242,7 +2242,7 @@ class Sql: and date_format(h.startTime, '%Y-%m-%d %T') - group by hgameTypeId + group by hgametypeId ,pname ,gt.base ,gt.category @@ -2259,14 +2259,14 @@ class Sql: when 'S' then 'S' else concat('Z', ) end - + ,upper(gt.limitType) desc ,maxbigblind desc ,s.name """ elif db_server == 'postgresql': self.query['playerDetailedStats'] = """ - select AS hgametypeid + select AS hgametypeid , AS pname ,gt.base ,gt.category @@ -2352,7 +2352,7 @@ class Sql: ,variance(hp.totalProfit/100.0) AS variance from HandsPlayers hp inner join Hands h on (h.id = hp.handId) - inner join Gametypes gt on (gt.Id = h.gameTypeId) + inner join Gametypes gt on (gt.Id = h.gametypeId) inner join Sites s on (s.Id = gt.siteId) inner join Players p on (p.Id = hp.playerId) where hp.playerId in @@ -2363,7 +2363,7 @@ class Sql: and to_char(h.startTime, 'YYYY-MM-DD HH24:MI:SS') - group by hgameTypeId + group by hgametypeId ,pname ,gt.base ,gt.category @@ -2381,14 +2381,14 @@ class Sql: when '0' then 'Y' else 'Z'|| end - + ,upper(gt.limitType) desc ,maxbigblind desc ,s.name """ elif db_server == 'sqlite': self.query['playerDetailedStats'] = """ - select AS hgametypeid + select AS hgametypeid , AS pname ,gt.base ,gt.category AS category @@ -2474,7 +2474,7 @@ class Sql: ,variance(hp.totalProfit/100.0) AS variance from HandsPlayers hp inner join Hands h on (h.id = hp.handId) - inner join Gametypes gt on (gt.Id = h.gameTypeId) + inner join Gametypes gt on (gt.Id = h.gametypeId) inner join Sites s on (s.Id = gt.siteId) inner join Players p on (p.Id = hp.playerId) where hp.playerId in @@ -2485,7 +2485,7 @@ class Sql: and datetime(h.startTime) - group by hgameTypeId + group by hgametypeId ,hp.playerId ,gt.base ,gt.category @@ -2503,7 +2503,7 @@ class Sql: when '0' then 'Y' else 'Z'|| end - + ,upper(gt.limitType) desc ,max(gt.bigBlind) desc ,s.name @@ -2693,7 +2693,7 @@ class Sql: ,format( sum(activeSeats*HDs)/(sum(HDs)+0.0), 2) AS AvgSeats from Gametypes gt inner join Sites s on s.Id = gt.siteId - inner join HudCache hc on hc.gameTypeId = gt.Id + inner join HudCache hc on hc.gametypeId = gt.Id where hc.playerId in and and hc.activeSeats @@ -2714,7 +2714,7 @@ class Sql: else variance(hprof.profit/100.0) end as variance from - (select hp.handId, as gtId, hp.totalProfit as profit + (select hp.handId, as gtId, hp.totalProfit as profit from HandsPlayers hp inner join Hands h ON h.id = hp.handId where hp.playerId in @@ -2798,7 +2798,7 @@ class Sql: ,to_char(sum(activeSeats*HDs)/(sum(HDs)+0.0),'90D00') AS AvgSeats from Gametypes gt inner join Sites s on s.Id = gt.siteId - inner join HudCache hc on hc.gameTypeId = gt.Id + inner join HudCache hc on hc.gametypeId = gt.Id where hc.playerId in and and hc.activeSeats @@ -2819,7 +2819,7 @@ class Sql: else variance(hprof.profit/100.0) end as variance from - (select hp.handId, as gtId, hp.totalProfit as profit + (select hp.handId, as gtId, hp.totalProfit as profit from HandsPlayers hp inner join Hands h ON (h.id = hp.handId) where hp.playerId in @@ -2921,7 +2921,7 @@ class Sql: ,format( sum(activeSeats*HDs)/(sum(HDs)+0.0), 2) AS AvgSeats from Gametypes gt inner join Sites s on s.Id = gt.siteId - inner join HudCache hc on hc.gameTypeId = gt.Id + inner join HudCache hc on hc.gametypeId = gt.Id where hc.playerId in and and hc.activeSeats @@ -2951,7 +2951,7 @@ class Sql: else variance(hprof.profit/100.0) end as variance from - (select hp.handId, as gtId, hp.position + (select hp.handId, as gtId, hp.position , hp.totalProfit as profit from HandsPlayers hp inner join Hands h ON (h.id = hp.handId) @@ -3060,7 +3060,7 @@ class Sql: ,to_char(sum(activeSeats*HDs)/(sum(HDs)+0.0),'90D00') AS AvgSeats from Gametypes gt inner join Sites s on (s.Id = gt.siteId) - inner join HudCache hc on (hc.gameTypeId = gt.Id) + inner join HudCache hc on (hc.gametypeId = gt.Id) where hc.playerId in and and hc.activeSeats @@ -3090,14 +3090,14 @@ class Sql: else variance(hprof.profit/100.0) end as variance from - (select hp.handId, as gtId, hp.position + (select hp.handId, as gtId, hp.position , hp.totalProfit as profit from HandsPlayers hp inner join Hands h ON (h.id = hp.handId) where hp.playerId in and hp.tourneysPlayersId IS NULL and to_char(h.startTime, 'YYYY-MM-DD') - group by hp.handId, gameTypeId, hp.position, hp.totalProfit + group by hp.handId, gametypeId, hp.position, hp.totalProfit ) hprof group by hprof.gtId, PlPosition ) hprof2 @@ -3191,7 +3191,7 @@ class Sql: SELECT UNIX_TIMESTAMP(h.startTime) as time, hp.handId, hp.startCash, hp.winnings, hp.totalProfit FROM HandsPlayers hp INNER JOIN Hands h on (h.id = hp.handId) - INNER JOIN Gametypes gt on (gt.Id = h.gameTypeId) + INNER JOIN Gametypes gt on (gt.Id = h.gametypeId) INNER JOIN Sites s on (s.Id = gt.siteId) INNER JOIN Players p on (p.Id = hp.playerId) WHERE hp.playerId in @@ -3203,7 +3203,7 @@ class Sql: SELECT EXTRACT(epoch from h.startTime) as time, hp.handId, hp.startCash, hp.winnings, hp.totalProfit FROM HandsPlayers hp INNER JOIN Hands h on (h.id = hp.handId) - INNER JOIN Gametypes gt on (gt.Id = h.gameTypeId) + INNER JOIN Gametypes gt on (gt.Id = h.gametypeId) INNER JOIN Sites s on (s.Id = gt.siteId) INNER JOIN Players p on (p.Id = hp.playerId) WHERE hp.playerId in @@ -3215,7 +3215,7 @@ class Sql: SELECT STRFTIME('', h.startTime) as time, hp.handId, hp.startCash, hp.winnings, hp.totalProfit FROM HandsPlayers hp INNER JOIN Hands h on (h.id = hp.handId) - INNER JOIN Gametypes gt on (gt.Id = h.gameTypeId) + INNER JOIN Gametypes gt on (gt.Id = h.gametypeId) INNER JOIN Sites s on (s.Id = gt.siteId) INNER JOIN Players p on (p.Id = hp.playerId) WHERE hp.playerId in