djrscally/pubg_reporting

Add player that still had games with others

TTAbwill opened this issue · 4 comments

Hey there, its me again ;)

Szenario:
I added player A and run the sync. Everything works perfect.
Then i added player B who had a match with player A yesterday. Sync works, but:

Issue:
The stats of the match player A and B played together is not showing up in player_match_stats for player B.

Ah, good spot. That one is because...

    process_matches = []

    for player in api.players:
        for match in player['relationships']['matches']['data']:
            q = sess.query(Match).filter_by(match_id=match['id'])
            # If we already added it, or it already exists in the database
            if (match['id'] in process_matches) or (sess.query(q.exists()).one()[0]):
                continue
            else:
                process_matches.append(match['id'])

We only sync matches that don't already exist in the database, because I didn't consider the case of a player who played in a match being added AFTER the sync had run and included that match. I'll tweak it to check if player match stats exist instead of just the raw match, and sync if not.

@TTAbwill Fixed - pull master for the update. Note that a bunch more optimisation efforts went into master last night too so there's more than just this change.

Still greate work. I'll try. Thank you!