1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed Something odd with statistics since upgrade ?

Discussion in 'Resolved Bug Reports' started by Stemmy, Jan 6, 2016.

  1. Stemmy

    Stemmy Active Member

    image.png I upgraded to 1.5 last week and since then the statistics section seems to have had a wobble.

    If I look at weekly statistics it looks like this ??
    tyteen4a03 and CyclingTribe like this.
  2. Brogan

    Brogan XenForo Moderator Staff Member

    The same is happening here so I have moved this to bug reports.
  3. Stemmy

    Stemmy Active Member

    Ok thanks Brogan - I'll stop looking for the problem :)
  4. Mouth

    Mouth Well-Known Member

    FYI, set the end date prior to 2016 (eg. 31/Dec/2015) and it works fine.
  5. The Sandman

    The Sandman Well-Known Member

    Late Y2K bug?
    Itworx4me and Izagar like this.
  6. HotCopper

    HotCopper Member

  7. Mike

    Mike XenForo Developer Staff Member

    Hmm, I wrote a post to this, but I guess I never submitted it.

    It was down to a quirk of ISO-8601 week numbers and the year that they apply to. (For example, Jan 1 - 3 2016 were considered to be part of week 53 2015.) I made the handling consistently use the year number based on that week number and it sorts it.
    thedude and The Sandman like this.
  8. StarArmy

    StarArmy Active Member

    I noticed this too on my forum. I see the prefix says "fixed" now so I can safely assume this will be fixed in the next version release?
  9. Mike

    Mike XenForo Developer Staff Member

    Yes, the fix will be in the next release.
  10. Zenexer

    Zenexer Active Member

    Here's a patch file for those of you who want to fix it on your own. If you're not sure how to apply a patch and you just want a quick fix:

    Open library/XenForo/ControllerAdmin/Stats.php in a text editor. Scroll down until you see:
    'weekly' => array(
    'printDateFormat' => '\WW Y',
    'groupDateFormat' => 'YW'
    Notice the two instances of "Y". That's the wrong year code for weekly statistics. Change both of them to "o". Yours should now look like this:
    'weekly' => array(
    'printDateFormat' => '\WW o',
    'groupDateFormat' => 'oW'
    Hopefully you didn't come up with some complicated solution, @Mike. ;) Here's the description for "o":
    The MySQL changes in the patch aren't strictly necessary, but they should (theoretically) increase performance.

    Attached Files:

    Last edited: Jan 10, 2016
    Fuhrmann, ozzy47 and NamePros like this.
  11. thedude

    thedude Well-Known Member

    @Zenexer Nice quick patch


    Needlessly smug though
  12. Mike

    Mike XenForo Developer Staff Member

    That's a partial fix, though the code in the controller isn't actually used. The MySQL change definitely is necessary and there are some other spread out PHP changes in the stats formatting to use "o".
    Zenexer likes this.
  13. Zenexer

    Zenexer Active Member

    Haha, well, it certainly doesn't benefit me if a complicated alternative ends up in a release. Optimization is important. The only reason I mentioned it is because often they release a patch for simple fixes. My apologies if it was offensive.

    The MySQL change is necessary to get a perfect chart, but not to get a "good enough" result, which is what I figured most people would want for now. The controller fix is what got it working on our site, but we've made a lot of other changes in that general vicinity, so it's possible it's not relevant to a vanilla site. I didn't need to change anything else to get proper results specifically for weekly stats. The MySQL query doesn't actually return the year/week numbers; one week just ends up split into two adjacent groups if the query isn't fixed.

    Edit: I think I see why that patch worked for us even though that code isn't used. It wouldn't work in years where there are 4 or more days of the overlapping week in January. I'll update the patch with a quick fix.
    Last edited: Jan 11, 2016
  14. Zenexer

    Zenexer Active Member

    Updated patch based on @Mike's hints :)

    Attached Files:

  15. The Sandman

    The Sandman Well-Known Member

    Fixed in XF 1.5.5! :D
    Aurèle, thedude and StarArmy like this.

Share This Page