golf/abc_base.py
def mergePlayerResults(self, newPlayerResultList):
        """
        Merges the existing players from the database with the new players
        TODO: Need to return response time
        """
        a = datetime.now()
        playerResultList = []
        try:
            rounds = Round.objects.filter(tournament_round=self.tournamentRoundId)
        except (Round.DoesNotExist):
            print ('there are not any rounds for this tournament_round')
            print (self.tournamentRoundId)
            return newPlayerResultList

        if (len(rounds) == 0):
            return newPlayerResultList
            
        #TODO: Normalizing when I don't need to...
        for round in rounds:
            player = {}
            player['clubMemberNumber'] = round.player.club_member_number
            player['playerName'] = round.player.name
            player['handicapIndex'] = round.handicap_index
            player['scorecardId'] = round.scorecard.id
            player['round'] = {}
            player['round']['courseTeeId'] = round.course_tee.id
            player['round']['courseHCP'] = round.course_handicap
            player['round']['totalOut'] = round.total_out
            player['round']['totalIn'] = round.total_in
            player['round']['total'] = round.total
            player['round']['totalNet'] = round.net
            player['round']['score'] = {}
            for i in range(18):
                ss = Score.objects.filter(round=round.id, tee__hole__number=int(i+1)).values()[0]
                player['round']['score']['hole'+str(i)] = ss['score']
            playerResultList.append(player)
        for player in newPlayerResultList:
            nfound = True
            for result in playerResultList:
                if (result['clubMemberNumber'] == player['clubMemberNumber']):
                    nfound = False
                    result['playerName'] = player['playerName']
                    result['handicapIndex'] = player['handicapIndex']
                    result['round'] = {}
                    result['round']['courseTeeId'] = player['round']['courseTeeId']
                    result['round']['courseHCP'] = player['round']['courseHandicap']
                    result['round']['totalOut'] = player['round']['totalOut']
                    result['round']['totalIn'] = player['round']['totalIn']
                    result['round']['total'] = player['round']['total']
                    result['round']['totalNet'] = player['round']['totalNet']
                    result['round']['score'] = {}
                    for i in range(18):
                        result['score']['hole'+str(i)] = player.score['hole'+str(i)]
                    pass
            if (nfound):
                playerResultList.append(player)
        c = datetime.now() - a
        print('mergePlayerResults time: '+str(c.seconds))
        return playerResultList

        Merges the existing players from the database with the new players
        TODO: Need to return response time
        
Merges the existing players from the database with the new players
TODO: Need to return response time
Merges the existing players from the database with the new players TODO : Need to return response time
def mergePlayerResults(self, newPlayerResultList):
        a = datetime.now()
        playerResultList = []
        try:
            rounds = Round.objects.filter(tournament_round=self.tournamentRoundId)
        except (Round.DoesNotExist):
            print ('there are not any rounds for this tournament_round')
            print (self.tournamentRoundId)
            return newPlayerResultList
        if (len(rounds) == 0):
            return newPlayerResultList
        for round in rounds:
            player = {}
            player['clubMemberNumber'] = round.player.club_member_number
            player['playerName'] = round.player.name
            player['handicapIndex'] = round.handicap_index
            player['scorecardId'] = round.scorecard.id
            player['round'] = {}
            player['round']['courseTeeId'] = round.course_tee.id
            player['round']['courseHCP'] = round.course_handicap
            player['round']['totalOut'] = round.total_out
            player['round']['totalIn'] = round.total_in
            player['round']['total'] = round.total
            player['round']['totalNet'] = round.net
            player['round']['score'] = {}
            for i in range(18):
                ss = Score.objects.filter(round=round.id, tee__hole__number=int(i+1)).values()[0]
                player['round']['score']['hole'+str(i)] = ss['score']
            playerResultList.append(player)
        for player in newPlayerResultList:
            nfound = True
            for result in playerResultList:
                if (result['clubMemberNumber'] == player['clubMemberNumber']):
                    nfound = False
                    result['playerName'] = player['playerName']
                    result['handicapIndex'] = player['handicapIndex']
                    result['round'] = {}
                    result['round']['courseTeeId'] = player['round']['courseTeeId']
                    result['round']['courseHCP'] = player['round']['courseHandicap']
                    result['round']['totalOut'] = player['round']['totalOut']
                    result['round']['totalIn'] = player['round']['totalIn']
                    result['round']['total'] = player['round']['total']
                    result['round']['totalNet'] = player['round']['totalNet']
                    result['round']['score'] = {}
                    for i in range(18):
                        result['score']['hole'+str(i)] = player.score['hole'+str(i)]
                    pass
            if (nfound):
                playerResultList.append(player)
        c = datetime.now() - a
        print('mergePlayerResults time: '+str(c.seconds))
        return playerResultList
def mergePlayerResults ( self , newPlayerResultList ) : a = datetime . now ( ) playerResultList = [ ] try : rounds = Round . objects . filter ( tournament_round = self . tournamentRoundId ) except ( Round . DoesNotExist ) : print ( 'there are not any rounds for this tournament_round' ) print ( self . tournamentRoundId ) return newPlayerResultList if ( len ( rounds ) == 0 ) : return newPlayerResultList for round in rounds : player = { } player [ 'clubMemberNumber' ] = round . player . club_member_number player [ 'playerName' ] = round . player . name player [ 'handicapIndex' ] = round . handicap_index player [ 'scorecardId' ] = round . scorecard . id player [ 'round' ] = { } player [ 'round' ] [ 'courseTeeId' ] = round . course_tee . id player [ 'round' ] [ 'courseHCP' ] = round . course_handicap player [ 'round' ] [ 'totalOut' ] = round . total_out player [ 'round' ] [ 'totalIn' ] = round . total_in player [ 'round' ] [ 'total' ] = round . total player [ 'round' ] [ 'totalNet' ] = round . net player [ 'round' ] [ 'score' ] = { } for i in range ( 18 ) : ss = Score . objects . filter ( round = round . id , tee__hole__number = int ( i + 1 ) ) . values ( ) [ 0 ] player [ 'round' ] [ 'score' ] [ 'hole' + str ( i ) ] = ss [ 'score' ] playerResultList . append ( player ) for player in newPlayerResultList : nfound = True for result in playerResultList : if ( result [ 'clubMemberNumber' ] == player [ 'clubMemberNumber' ] ) : nfound = False result [ 'playerName' ] = player [ 'playerName' ] result [ 'handicapIndex' ] = player [ 'handicapIndex' ] result [ 'round' ] = { } result [ 'round' ] [ 'courseTeeId' ] = player [ 'round' ] [ 'courseTeeId' ] result [ 'round' ] [ 'courseHCP' ] = player [ 'round' ] [ 'courseHandicap' ] result [ 'round' ] [ 'totalOut' ] = player [ 'round' ] [ 'totalOut' ] result [ 'round' ] [ 'totalIn' ] = player [ 'round' ] [ 'totalIn' ] result [ 'round' ] [ 'total' ] = player [ 'round' ] [ 'total' ] result [ 'round' ] [ 'totalNet' ] = player [ 'round' ] [ 'totalNet' ] result [ 'round' ] [ 'score' ] = { } for i in range ( 18 ) : result [ 'score' ] [ 'hole' + str ( i ) ] = player . score [ 'hole' + str ( i ) ] pass if ( nfound ) : playerResultList . append ( player ) c = datetime . now ( ) - a print ( 'mergePlayerResults time: ' + str ( c . seconds ) ) return playerResultList
Merges the existing players from the database with the new players
TODO: Need to return response time
Merges the existing players from the database with the new players TODO : Need to return response time
"""
        Merges the existing players from the database with the new players
        TODO: Need to return response time
        """ #TODO: Normalizing when I don't need to...
self
newPlayerResultList