From 5fee5136a9cc43fc0eb8c917ebf0bf10f87a242b Mon Sep 17 00:00:00 2001 From: steffen123 Date: Sun, 11 Jul 2010 08:05:54 +0200 Subject: [PATCH] DB: renamed Hands.handStart to Hands.startTime for consistency --- pyfpdb/AlchemyMappings.py | 4 +-- pyfpdb/AlchemyTables.py | 2 +- pyfpdb/Database.py | 8 ++--- pyfpdb/DerivedStats.py | 2 +- pyfpdb/SQL.py | 70 +++++++++++++++++++-------------------- 5 files changed, 43 insertions(+), 43 deletions(-) diff --git a/pyfpdb/AlchemyMappings.py b/pyfpdb/AlchemyMappings.py index f4884de3..15cdf70d 100644 --- a/pyfpdb/AlchemyMappings.py +++ b/pyfpdb/AlchemyMappings.py @@ -193,8 +193,8 @@ class HandInternal(DerivedStats): setattr(tour, col, hand_val) elif col == 'koBounty': setattr(tour, col, max(db_val, hand_val)) - elif col == 'tourStartTime' and hand.handStart: - setattr(tour, col, min(db_val, hand.handStart)) + elif col == 'tourStartTime' and hand.startTime: + setattr(tour, col, min(db_val, hand.startTime)) if tour.entries is None and tour_type.sng: tour.entries = tour_type.maxSeats diff --git a/pyfpdb/AlchemyTables.py b/pyfpdb/AlchemyTables.py index 61feb0d5..84c4b9f0 100644 --- a/pyfpdb/AlchemyTables.py +++ b/pyfpdb/AlchemyTables.py @@ -65,7 +65,7 @@ hands_table = Table('Hands', metadata, Column('tableName', String(30), nullable=False), Column('siteHandNo', BigIntColumn, nullable=False), Column('gametypeId', SmallInteger, ForeignKey('Gametypes.id'), nullable=False), - Column('handStart', DateTime, nullable=False), + Column('startTime', DateTime, nullable=False), Column('importTime', DateTime, nullable=False), Column('seats', SmallInteger, nullable=False), Column('maxSeats', SmallInteger, nullable=False), diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 5e591d1b..71034563 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -74,7 +74,7 @@ except ImportError: use_numpy = False -DB_VERSION = 129 +DB_VERSION = 130 # Variance created as sqlite has a bunch of undefined aggregate functions. @@ -1423,9 +1423,9 @@ class Database: where = "" else: where = "where ( hp.playerId not in " + str(tuple(self.hero_ids.values())) \ - + " and h.handStart > '" + v_start + "')" \ + + " and h.startTime > '" + v_start + "')" \ + " or ( hp.playerId in " + str(tuple(self.hero_ids.values())) \ - + " and h.handStart > '" + h_start + "')" + + " and h.startTime > '" + h_start + "')" rebuild_sql = self.sql.query['rebuildHudCache'].replace('', where) self.get_cursor().execute(self.sql.query['clearHudCache']) @@ -1541,7 +1541,7 @@ class Database: p['gameTypeId'], p['siteHandNo'], 0, # tourneyId: 0 means not a tourney hand - p['handStart'], + p['startTime'], datetime.today(), #importtime p['seats'], p['maxSeats'], diff --git a/pyfpdb/DerivedStats.py b/pyfpdb/DerivedStats.py index bae557ad..96928486 100644 --- a/pyfpdb/DerivedStats.py +++ b/pyfpdb/DerivedStats.py @@ -97,7 +97,7 @@ class DerivedStats(): self.hands['tableName'] = hand.tablename self.hands['siteHandNo'] = hand.handid self.hands['gametypeId'] = None # Leave None, handled later after checking db - self.hands['handStart'] = hand.startTime # format this! + self.hands['startTime'] = hand.startTime # format this! self.hands['importTime'] = None self.hands['seats'] = self.countPlayers(hand) self.hands['maxSeats'] = hand.maxseats diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 415fe3af..47c9740f 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -255,7 +255,7 @@ class Sql: siteHandNo BIGINT NOT NULL, tourneyId INT UNSIGNED NOT NULL, gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), - handStart DATETIME NOT NULL, + startTime DATETIME NOT NULL, importTime DATETIME NOT NULL, seats TINYINT NOT NULL, maxSeats TINYINT NOT NULL, @@ -292,7 +292,7 @@ class Sql: siteHandNo BIGINT NOT NULL, tourneyId INT NOT NULL, gametypeId INT NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), - handStart timestamp without time zone NOT NULL, + startTime timestamp without time zone NOT NULL, importTime timestamp without time zone NOT NULL, seats SMALLINT NOT NULL, maxSeats SMALLINT NOT NULL, @@ -328,7 +328,7 @@ class Sql: siteHandNo INT NOT NULL, tourneyId INT NOT NULL, gametypeId INT NOT NULL, - handStart REAL NOT NULL, + startTime REAL NOT NULL, importTime REAL NOT NULL, seats INT NOT NULL, maxSeats INT NOT NULL, @@ -1620,7 +1620,7 @@ class Sql: AND h2.seats between %s and %s ) ) - ORDER BY h.handStart desc, hp2.PlayerId + ORDER BY h.startTime desc, hp2.PlayerId /* order rows by handstart descending so that we can stop reading rows when there's a gap over X minutes between hands (ie. when we get back to start of the session */ @@ -1723,7 +1723,7 @@ class Sql: AND h2.seats between %s and %s ) ) - ORDER BY h.handStart desc, hp2.PlayerId + ORDER BY h.startTime desc, hp2.PlayerId /* order rows by handstart descending so that we can stop reading rows when there's a gap over X minutes between hands (ie. when we get back to start of the session */ @@ -1826,7 +1826,7 @@ class Sql: AND h2.seats between %s and %s ) ) - ORDER BY h.handStart desc, hp2.PlayerId + ORDER BY h.startTime desc, hp2.PlayerId /* order rows by handstart descending so that we can stop reading rows when there's a gap over X minutes between hands (ie. when we get back to start of the session */ @@ -1896,23 +1896,23 @@ class Sql: self.query['get_hand_1day_ago'] = """ select coalesce(max(id),0) from Hands - where handStart < date_sub(utc_timestamp(), interval '1' day)""" + where startTime < date_sub(utc_timestamp(), interval '1' day)""" elif db_server == 'postgresql': self.query['get_hand_1day_ago'] = """ select coalesce(max(id),0) from Hands - where handStart < now() at time zone 'UTC' - interval '1 day'""" + where startTime < now() at time zone 'UTC' - interval '1 day'""" elif db_server == 'sqlite': self.query['get_hand_1day_ago'] = """ select coalesce(max(id),0) from Hands - where handStart < strftime('%J', 'now') - 1""" + where startTime < strftime('%J', 'now') - 1""" # not used yet ... # gets a date, would need to use handsplayers (not hudcache) to get exact hand Id if db_server == 'mysql': self.query['get_date_nhands_ago'] = """ - select concat( 'd', date_format(max(h.handStart), '%Y%m%d') ) + select concat( 'd', date_format(max(h.startTime), '%Y%m%d') ) from (select hp.playerId ,coalesce(greatest(max(hp.handId)-%s,1),1) as maxminusx from HandsPlayers hp @@ -1924,7 +1924,7 @@ class Sql: """ elif db_server == 'postgresql': self.query['get_date_nhands_ago'] = """ - select 'd' || to_char(max(h3.handStart), 'YYMMDD') + select 'd' || to_char(max(h3.startTime), 'YYMMDD') from (select hp.playerId ,coalesce(greatest(max(hp.handId)-%s,1),1) as maxminusx from HandsPlayers hp @@ -1936,7 +1936,7 @@ class Sql: """ elif db_server == 'sqlite': # untested guess at query: self.query['get_date_nhands_ago'] = """ - select 'd' || strftime(max(h3.handStart), 'YYMMDD') + select 'd' || strftime(max(h3.startTime), 'YYMMDD') from (select hp.playerId ,coalesce(greatest(max(hp.handId)-%s,1),1) as maxminusx from HandsPlayers hp @@ -2043,7 +2043,7 @@ class Sql: and h.seats - and date_format(h.handStart, '%Y-%m-%d %T') + and date_format(h.startTime, '%Y-%m-%d %T') group by hgameTypeId ,pname ,gt.base @@ -2140,7 +2140,7 @@ class Sql: and h.seats - and to_char(h.handStart, 'YYYY-MM-DD HH24:MI:SS') + and to_char(h.startTime, 'YYYY-MM-DD HH24:MI:SS') group by hgameTypeId ,pname ,gt.base @@ -2238,7 +2238,7 @@ class Sql: and h.seats - and datetime(h.handStart) + and datetime(h.startTime) group by hgameTypeId ,hp.playerId ,gt.base @@ -2396,7 +2396,7 @@ class Sql: inner join Hands h ON h.id = hp.handId where hp.playerId in and hp.tourneysPlayersId IS NULL - and date_format(h.handStart, '%Y-%m-%d') + and date_format(h.startTime, '%Y-%m-%d') group by hp.handId, gtId, hp.totalProfit ) hprof group by hprof.gtId @@ -2499,7 +2499,7 @@ class Sql: inner join Hands h ON (h.id = hp.handId) where hp.playerId in and hp.tourneysPlayersId IS NULL - and to_char(h.handStart, 'YYYY-MM-DD') + and to_char(h.startTime, 'YYYY-MM-DD') group by hp.handId, gtId, hp.totalProfit ) hprof group by hprof.gtId @@ -2634,7 +2634,7 @@ class Sql: inner join Hands h ON (h.id = hp.handId) where hp.playerId in and hp.tourneysPlayersId IS NULL - and date_format(h.handStart, '%Y-%m-%d') + and date_format(h.startTime, '%Y-%m-%d') group by hp.handId, gtId, hp.position, hp.totalProfit ) hprof group by hprof.gtId, PlPosition @@ -2771,7 +2771,7 @@ class Sql: inner join Hands h ON (h.id = hp.handId) where hp.playerId in and hp.tourneysPlayersId IS NULL - and to_char(h.handStart, 'YYYY-MM-DD') + and to_char(h.startTime, 'YYYY-MM-DD') group by hp.handId, gameTypeId, hp.position, hp.totalProfit ) hprof group by hprof.gtId, PlPosition @@ -2792,13 +2792,13 @@ class Sql: INNER JOIN Gametypes gt ON (gt.id = h.gametypeId) WHERE pl.id in AND pl.siteId in - AND h.handStart > '' - AND h.handStart < '' + AND h.startTime > '' + AND h.startTime < '' AND hp.tourneysPlayersId IS NULL - GROUP BY h.handStart, hp.handId, hp.sawShowdown, hp.totalProfit - ORDER BY h.handStart""" + GROUP BY h.startTime, hp.handId, hp.sawShowdown, hp.totalProfit + ORDER BY h.startTime""" #################################### @@ -2806,38 +2806,38 @@ class Sql: #################################### if db_server == 'mysql': self.query['sessionStats'] = """ - SELECT UNIX_TIMESTAMP(h.handStart) as time, hp.handId, hp.startCash, hp.winnings, hp.totalProfit + 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 Sites s on (s.Id = gt.siteId) INNER JOIN Players p on (p.Id = hp.playerId) WHERE hp.playerId in - AND date_format(h.handStart, '%Y-%m-%d') + AND date_format(h.startTime, '%Y-%m-%d') AND hp.tourneysPlayersId IS NULL ORDER by time""" elif db_server == 'postgresql': self.query['sessionStats'] = """ - SELECT EXTRACT(epoch from h.handStart) as time, hp.handId, hp.startCash, hp.winnings, hp.totalProfit + 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 Sites s on (s.Id = gt.siteId) INNER JOIN Players p on (p.Id = hp.playerId) WHERE hp.playerId in - AND h.handStart + AND h.startTime AND hp.tourneysPlayersId IS NULL ORDER by time""" elif db_server == 'sqlite': self.query['sessionStats'] = """ - SELECT STRFTIME('', h.handStart) as time, hp.handId, hp.startCash, hp.winnings, hp.totalProfit + 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 Sites s on (s.Id = gt.siteId) INNER JOIN Players p on (p.Id = hp.playerId) WHERE hp.playerId in - AND h.handStart + AND h.startTime AND hp.tourneysPlayersId IS NULL ORDER by time""" @@ -2946,7 +2946,7 @@ class Sql: else 'E' end AS hc_position ,hp.tourneyTypeId - ,date_format(h.handStart, 'd%y%m%d') + ,date_format(h.startTime, 'd%y%m%d') ,count(1) ,sum(wonWhenSeenStreet1) ,sum(wonAtSD) @@ -3025,7 +3025,7 @@ class Sql: ,h.seats ,hc_position ,hp.tourneyTypeId - ,date_format(h.handStart, 'd%y%m%d') + ,date_format(h.startTime, 'd%y%m%d') """ elif db_server == 'postgresql': self.query['rebuildHudCache'] = """ @@ -3125,7 +3125,7 @@ class Sql: else 'E' end AS hc_position ,hp.tourneyTypeId - ,'d' || to_char(h.handStart, 'YYMMDD') + ,'d' || to_char(h.startTime, 'YYMMDD') ,count(1) ,sum(wonWhenSeenStreet1) ,sum(wonAtSD) @@ -3204,7 +3204,7 @@ class Sql: ,h.seats ,hc_position ,hp.tourneyTypeId - ,to_char(h.handStart, 'YYMMDD') + ,to_char(h.startTime, 'YYMMDD') """ else: # assume sqlite self.query['rebuildHudCache'] = """ @@ -3304,7 +3304,7 @@ class Sql: else 'E' end AS hc_position ,hp.tourneyTypeId - ,'d' || substr(strftime('%Y%m%d', h.handStart),3,7) + ,'d' || substr(strftime('%Y%m%d', h.startTime),3,7) ,count(1) ,sum(wonWhenSeenStreet1) ,sum(wonAtSD) @@ -3383,7 +3383,7 @@ class Sql: ,h.seats ,hc_position ,hp.tourneyTypeId - ,'d' || substr(strftime('%Y%m%d', h.handStart),3,7) + ,'d' || substr(strftime('%Y%m%d', h.startTime),3,7) """ self.query['insert_hudcache'] = """