From 9e004e896211c1fee65f817c7f6e50d7055a5596 Mon Sep 17 00:00:00 2001 From: steffen123 Date: Thu, 15 Jul 2010 01:18:36 +0200 Subject: [PATCH] DB: remove default row for TT, allow HP.ttId to be NULL and remove default --- pyfpdb/Database.py | 14 +------------- pyfpdb/DerivedStats.py | 6 ++++-- pyfpdb/SQL.py | 12 ++++++------ 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index f35fe19a..329c3da9 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -74,7 +74,7 @@ except ImportError: use_numpy = False -DB_VERSION = 133 +DB_VERSION = 134 # Variance created as sqlite has a bunch of undefined aggregate functions. @@ -1408,18 +1408,6 @@ class Database: c.execute("INSERT INTO Sites (name,code) VALUES ('Partouche', 'PA')") c.execute("INSERT INTO Sites (name,code) VALUES ('Carbon', 'CA')") c.execute("INSERT INTO Sites (name,code) VALUES ('PKR', 'PK')") - if self.backend == self.SQLITE: - c.execute("""INSERT INTO TourneyTypes (id, siteId, currency, buyin, fee, category, limitType, - buyInChips, maxSeats, knockout, rebuy, addOn, speed, shootout, matrix) - VALUES (NULL, 1, 'USD', 0, 0, "NA", "NA", 0, 0, 0, 0, 0, NULL, 0, 0);""") - elif self.backend == self.PGSQL: - c.execute("""insert into TourneyTypes(siteId, currency, buyin, fee, category, limitType, - buyInChips, maxSeats, knockout, rebuy, addOn, speed, shootout, matrix) - values (1, 'USD', 0, 0, "NA", "NA", 0, 0, False, False, False, null, False, False);""") - elif self.backend == self.MYSQL_INNODB: - c.execute("""insert into TourneyTypes(id, siteId, currency, buyin, fee, category, limitType, - buyInChips, maxSeats, knockout, rebuy, addOn, speed, shootout, matrix) - values (DEFAULT, 1, 'USD', 0, 0, "NA", "NA", 0, 0, False, False, False, null, False, False);""") #end def fillDefaultData def rebuild_indexes(self, start=None): diff --git a/pyfpdb/DerivedStats.py b/pyfpdb/DerivedStats.py index f34a8673..9bd8bbd2 100644 --- a/pyfpdb/DerivedStats.py +++ b/pyfpdb/DerivedStats.py @@ -59,6 +59,8 @@ class DerivedStats(): self.handsplayers[player[1]]['foldSbToStealChance'] = False self.handsplayers[player[1]]['foldedSbToSteal'] = False self.handsplayers[player[1]]['foldedBbToSteal'] = False + self.handsplayers[player[1]]['tourneyTypeId'] = None + for i in range(5): self.handsplayers[player[1]]['street%dCalls' % i] = 0 self.handsplayers[player[1]]['street%dBets' % i] = 0 @@ -70,9 +72,8 @@ class DerivedStats(): self.handsplayers[player[1]]['street%dCheckCallRaiseDone' %i] = False self.handsplayers[player[1]]['otherRaisedStreet%d' %i] = False self.handsplayers[player[1]]['foldToOtherRaisedStreet%d' %i] = False - + #FIXME - Everything below this point is incomplete. - self.handsplayers[player[1]]['tourneyTypeId'] = 1 for i in range(1,5): self.handsplayers[player[1]]['foldToStreet%dCBChance' %i] = False self.handsplayers[player[1]]['foldToStreet%dCBDone' %i] = False @@ -141,6 +142,7 @@ class DerivedStats(): self.handsplayers[player[1]]['startCash'] = int(100 * Decimal(player[2])) self.handsplayers[player[1]]['sitout'] = False #TODO: implement actual sitout detection if hand.gametype["type"]=="tour": + self.handsplayers[player[1]]['tourneyTypeId']=hand.tourneyTypeId self.handsplayers[player[1]]['tourneysPlayersIds'] = hand.tourneysPlayersIds[player[1]] else: self.handsplayers[player[1]]['tourneysPlayersIds'] = None diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 515c8a24..1cd25bd3 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -554,7 +554,7 @@ class Sql: comment text, commentTs DATETIME, tourneysPlayersId BIGINT UNSIGNED, FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id), - tourneyTypeId SMALLINT UNSIGNED NOT NULL DEFAULT 1, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), + tourneyTypeId SMALLINT UNSIGNED, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), wonWhenSeenStreet1 FLOAT, wonWhenSeenStreet2 FLOAT, @@ -671,7 +671,7 @@ class Sql: comment text, commentTs timestamp without time zone, tourneysPlayersId BIGINT, FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id), - tourneyTypeId INT NOT NULL DEFAULT 1, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), + tourneyTypeId INT, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), wonWhenSeenStreet1 FLOAT, wonWhenSeenStreet2 FLOAT, @@ -787,7 +787,7 @@ class Sql: comment TEXT, commentTs REAL, tourneysPlayersId INT, - tourneyTypeId INT NOT NULL DEFAULT 1, + tourneyTypeId INT, wonWhenSeenStreet1 REAL, wonWhenSeenStreet2 REAL, @@ -981,7 +981,7 @@ class Sql: playerId INT UNSIGNED NOT NULL, FOREIGN KEY (playerId) REFERENCES Players(id), activeSeats SMALLINT NOT NULL, position CHAR(1), - tourneyTypeId SMALLINT UNSIGNED NOT NULL DEFAULT 1, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), + tourneyTypeId SMALLINT UNSIGNED, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), styleKey CHAR(7) NOT NULL, /* 1st char is style (A/T/H/S), other 6 are the key */ HDs INT NOT NULL, @@ -1082,7 +1082,7 @@ class Sql: playerId INT, FOREIGN KEY (playerId) REFERENCES Players(id), activeSeats SMALLINT, position CHAR(1), - tourneyTypeId INT DEFAULT 1, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), + tourneyTypeId INT, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id), styleKey CHAR(7) NOT NULL, /* 1st char is style (A/T/H/S), other 6 are the key */ HDs INT, @@ -1181,7 +1181,7 @@ class Sql: playerId INT, activeSeats INT, position TEXT, - tourneyTypeId INT DEFAULT 1, + tourneyTypeId INT, styleKey TEXT NOT NULL, /* 1st char is style (A/T/H/S), other 6 are the key */ HDs INT,