Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

Arena stats being calculated incorrectly #44

Open
stevschmid opened this issue Feb 2, 2016 · 6 comments
Open

Arena stats being calculated incorrectly #44

stevschmid opened this issue Feb 2, 2016 · 6 comments
Labels

Comments

@stevschmid
Copy link
Owner

cf. stevschmid/track-o-bot#66

@JustinasDaugela
Copy link

@stevschmid did you manage to reproduce the issue?

@mislav
Copy link
Contributor

mislav commented Sep 16, 2016

I experience a version of this bug where all averages are "0.0".

screen shot 2016-09-16 at 2 27 18 pm

The "Runs" column is accurate, as well as the histogram in the bottom. I expected to see data in other columns, though.

This isn't a template issue, since the JSON representation of this endpoint also reports most numbers as "0":

{
    "stats": {
        "as_hero": {
            "Druid": {
                "losses": 0,
                "runs": 6,
                "total": 0,
                "wins": 0
            },
            "Hunter": {
                "losses": 0,
                "total": 0,
                "wins": 0
            },
            "Mage": {
                "losses": 0,
                "runs": 17,
                "total": 0,
                "wins": 0
            },
            "Paladin": {
                "losses": 0,
                "runs": 12,
                "total": 0,
                "wins": 0
            },
            "Priest": {
                "losses": 0,
                "runs": 1,
                "total": 0,
                "wins": 0
            },
            "Rogue": {
                "losses": 0,
                "runs": 13,
                "total": 0,
                "wins": 0
            },
            "Shaman": {
                "losses": 0,
                "runs": 3,
                "total": 0,
                "wins": 0
            },
            "Warlock": {
                "losses": 0,
                "runs": 6,
                "total": 0,
                "wins": 0
            },
            "Warrior": {
                "losses": 0,
                "runs": 2,
                "total": 0,
                "wins": 0
            }
        },
        "count_by_wins": [
            2,
            8,
            9,
            8,
            5,
            5,
            13,
            3,
            3,
            0,
            0,
            1,
            3
        ],
        "overall": {
            "losses": 0,
            "runs": 60,
            "total": 0,
            "wins": 0
        }
    }
}

I couldn't reproduce locally in development. But, it's interesting that the numbers which are valid all come from user_arenas scope, while all numbers that are zero come from user_results.arena. I would presume that the user_results.arena scope is somehow busted in production mode, although looking at the code I can't imagine how.

The historical data about Arena runs is displayed correctly in the "History" and "Arena" tabs.

My username is summer-dalaran-mage-9338.

@coleww
Copy link
Contributor

coleww commented Oct 19, 2016

I was encountering the exact same bug as @mislav. Looking through the code, I noticed that the read_params action in the Stats module was pulling stuff from cookies that could have potentially messed with the user_results query. So I cleared my cookies just to be sure, and the bug went away! 👯

Unfortunately, I didn't check to see what was in my cookies before doing this. If I can get the bug to happen again I'll save that data to see if there is an easy way to catch it from the Stats module. But for now, clearing cookies seems to fix the problem.

EDIT: the problem seems to be with the mode cookie being set. To easily reproduce the bug, go to /profile/stats/decks select 'ranked' in the mode dropdown, then go to profile/stats/arena

@mislav
Copy link
Contributor

mislav commented Oct 20, 2016

Hot damn, @coleww. That totally did it! 🏆

I checked the cookies before 🔥ing them. There was the Google Analytics cookie (irrelevant, I suppose, the mode cookie set to "ranked", the time_range cookie set to last 3 days, and the main _webtracker_session cookie (encrypted).

I think the culprit was the mode cookie. Steps to break your Arena stats again:

  1. Go to Stats > Arena. The data looks fine.
  2. Go to Stats > Classes.
  3. Choose "Ranked" from the modes drop-down.
  4. Go to Stats > Arena. The data is now all messed up because of the mode=ranked cookie being persisted in the previous step.

To unbreak your cookie, however, just reset the mode with Stats > Classes: All Modes.

@stevschmid
Copy link
Owner Author

stevschmid commented Oct 20, 2016

The 0.0 bug is fixed and deployed! Thanks for the help guys.

@mislav
Copy link
Contributor

mislav commented Oct 20, 2016

For posterity: 041c753

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants