def test_gamestat_lookupID(): log = Log('test.log') gs = GameStat() gs.connectDB() needle = { 'GameID': 1, 'TeamID': 2, 'PlayerID': 3 } result = gs.lookupID(needle, log) assert len(result) == 1 needle = { 'GameID': 0, 'TeamID': 0, 'PlayerID': 0 } result = gs.lookupID(needle, log) assert len(result) == 0
def doCompile(self): # The game stats compiler does the following: # 1) Assemble list of player appearances self.appearances = self.getAppearanceList() print("Processing " + str(len(self.appearances)) + " records") self.log.message(str(len(self.appearances)) + " records\n") # 2) For each appearance: for item in self.appearances: # 3) Look up ID for this statline gs = GameStat() gs.connectDB() needle = { 'GameID': item['GameID'], 'TeamID': item['TeamID'], 'PlayerID': item['PlayerID'] } statID = gs.lookupID(needle, self.log) if len(statID) > 0: item['ID'] = statID[0] # 4) Calculate summary statistics item = self.assembleStatLine(item) # 5) Goalkeeper stats # 6) Calculate plus/minus item = self.assemblePlusMinus(item) # Save record in the log self.log.message(str(item)) # 7) Upsert those statistics as GameStat objects gs.saveDict(item, self.log) self.log.message('') # Trying a delay to prevent buffer space problems time.sleep(0.01) return True