# Wrong statistics

**URL:** https://meta.discourse.org/t/wrong-statistics/95340
**Category:** Bug
**Created:** [August 21, 2018, 6:32pm UTC](https://meta.discourse.org/t/wrong-statistics/95340 "2018-08-21T18:32:42Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![Jean-Michel25](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@Jean-Michel25](https://meta.discourse.org/u/Jean-Michel25)
#### Post date: [August 21, 2018, 6:32pm UTC](https://meta.discourse.org/t/wrong-statistics/95340/1 "2018-08-21T18:32:42Z")

</div>

Hello

Sometimes wrong statistics :  
Only few dates displayed, grouped stats (see picture) ?

Sometimes good statistics :  
Each date displayed, good stats.

Discourse : 2.1.0.beta4  
Of course form re-submit after date choice.

 ![image](https://global.discourse-cdn.com/meta/original/3X/9/d/9d32e60fab9b866ecb8544911649027098c7c822.png)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [August 22, 2018, 12:19am UTC](https://meta.discourse.org/t/wrong-statistics/95340/3 "2018-08-22T00:19:35Z")

</div>

Sorry I am unclear, what is wrong about this? It looks fine to me?

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [August 22, 2018, 1:18am UTC](https://meta.discourse.org/t/wrong-statistics/95340/4 "2018-08-22T01:18:53Z")

</div>

I see only 6 markers for the 7 week range.

This suggests that there were no user visits for the days that don’t have markers. @Jean-Michel25 do you know for a fact there were user visits for those other days? Is there any reason that you can think of that might explain why the counts are “rolled up” into weekly instead of daily? Why nothing is displayed for Aug 8 to Aug 21?

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [August 22, 2018, 6:10am UTC](https://meta.discourse.org/t/wrong-statistics/95340/6 "2018-08-22T06:10:37Z")

</div>

Before I dig too much, can you try to update to latest please ?

---

<div class="post-metadata">

### Author: ![Jean-Michel25](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@Jean-Michel25](https://meta.discourse.org/u/Jean-Michel25)
#### Post date: [August 22, 2018, 7:34am UTC](https://meta.discourse.org/t/wrong-statistics/95340/7 "2018-08-22T07:34:13Z")

</div>

I check the stats every day.  
Always over 100 users / day.

Sometimes I’ve 1 marker / day, sometimes only a few in the range…

This morning I try to give you printscreen of the 2 ways

---

<div class="post-metadata">

### Author: ![Jean-Michel25](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@Jean-Michel25](https://meta.discourse.org/u/Jean-Michel25)
#### Post date: [August 22, 2018, 7:41am UTC](https://meta.discourse.org/t/wrong-statistics/95340/8 "2018-08-22T07:41:25Z")

</div>

I can reproduce easyly the problem :

I try all the dates for the 1st param, from 2018-07-01 and up day by day.  
Each time, of course, I update (twice or more).  
The markers are ok for 2018-07-14 and plus (15, 16…).  
The markers are KO for 2018-07-13 and less (12, 11…)

 ![image](https://global.discourse-cdn.com/meta/original/3X/1/b/1bcd3955c6cd7479be0eb6d37c9b3975cffc6141.png)

 ![image](https://global.discourse-cdn.com/meta/original/3X/8/9/899f482102d60ccd4300a306c4af3bd63d033684.png)

And the “table” display is according to graph.

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [August 22, 2018, 7:42am UTC](https://meta.discourse.org/t/wrong-statistics/95340/9 "2018-08-22T07:42:41Z")

</div>

Ok I see what’s going on 👍 will push a fix today thx

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [August 22, 2018, 7:58am UTC](https://meta.discourse.org/t/wrong-statistics/95340/10 "2018-08-22T07:58:56Z")

</div>

Ok this is actually not a bug on dates, but our `collapseWeekly()` code will do this when there are more than 40 data points to make it easier to read.

@sam I feel like we should change it, to make sure it shows first and last date of the range, what do you think? Otherwise it can be disturbing.

---

<div class="post-metadata">

### Author: ![Jean-Michel25](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@Jean-Michel25](https://meta.discourse.org/u/Jean-Michel25)
#### Post date: [August 22, 2018, 8:05am UTC](https://meta.discourse.org/t/wrong-statistics/95340/11 "2018-08-22T08:05:15Z")

</div>

OK thanks for this

It would be is usefull having somewhere day average.  
Maybe a hover popup on markers ?

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 22, 2018, 8:59am UTC](https://meta.discourse.org/t/wrong-statistics/95340/14 "2018-08-22T08:59:53Z")

</div>

Whilst we’re looking at the dashboard … this is what I have this morning after upgrading last night (to v2.1.0.beta5 +7). Is this just a case of Sidekiq not having caught up? (but I see some Dashboard jobs have run).

 ![image](https://global.discourse-cdn.com/meta/original/3X/9/3/9329f36e2fddd1f14728eaf2d08267d8e6d384f6.png)

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [August 22, 2018, 9:01am UTC](https://meta.discourse.org/t/wrong-statistics/95340/15 "2018-08-22T09:01:34Z")

</div>

What are you talking of exactly? Something looks totally wrong?

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 22, 2018, 9:01am UTC](https://meta.discourse.org/t/wrong-statistics/95340/16 "2018-08-22T09:01:54Z")

</div>

Yesterday = Last 7 = Last 30

Interestingly, even before the upgrade, Last 7 equalled last 30 and there were odd hover stats saying "0 for previous 30 days "

Hope that helps.

Many thanks for looking into it.

PPS It doesn’t look like I’ve lost any history because historical graphs are fine. Just the dashboard aggregation seems odd.

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [August 22, 2018, 9:02am UTC](https://meta.discourse.org/t/wrong-statistics/95340/17 "2018-08-22T09:02:41Z")

</div>

Indeed, looks weird, will look.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [August 22, 2018, 9:07am UTC](https://meta.discourse.org/t/wrong-statistics/95340/18 "2018-08-22T09:07:27Z")

</div>

I just checked the SitePoint dashboard. It displays the same Y = 7 = 30 oddness.

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [August 22, 2018, 10:39am UTC](https://meta.discourse.org/t/wrong-statistics/95340/19 "2018-08-22T10:39:49Z")

</div>

Ok this should be fixed by:

[https://github.com/discourse/discourse/commit/87d443f070582351c211efff989adee39449c30c](https://github.com/discourse/discourse/commit/87d443f070582351c211efff989adee39449c30c)

I also added a test for this, time based tests are kind of complicated on the client side ATM (while being very easy on server side). I gave it a shot to ensure we are not regressing on this again in the future, this test might have erratic behaviour. I will track it in the next days and the next blood moon as it’s usually when time based tests fail…

Thanks for reporting this.

ℹ only the counters bug is fixed. The other question about collapsing chart is still being discussed internaly.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [August 22, 2018, 2:02pm UTC](https://meta.discourse.org/t/wrong-statistics/95340/20 "2018-08-22T14:02:01Z")

</div>

That’s fixed it thanks.

 ![image](https://global.discourse-cdn.com/meta/original/3X/d/6/d6406af48322bcffe87e50a063d3410764baf5ab.png)

Unfortunately it still tells me “Was 0 in the previous 30 day period” on the hover tooltip for Last 30.

But a big bug fixed, thank you!

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [August 22, 2018, 4:02pm UTC](https://meta.discourse.org/t/wrong-statistics/95340/21 "2018-08-22T16:02:54Z")

</div>

Yes I’m aware of this. It’s not a bug, it’s simply that “prev30days” is not implemented for this report. It will work for some reports if you look closely.

However, I feel like I should just better handle this so I pushed this commit:

[https://github.com/discourse/discourse/commit/c08dea386b46672be1e69a9ecb10d626bdd84d32](https://github.com/discourse/discourse/commit/c08dea386b46672be1e69a9ecb10d626bdd84d32)

If there’s no `prev30days` data in the report, it won’t show the trending icons anymore. This commit has also an example of how to add this to a report. #pr-welcome if someone wants to add it to other reports.

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [August 30, 2018, 12:32pm UTC](https://meta.discourse.org/t/wrong-statistics/95340/22 "2018-08-30T12:32:49Z")

</div>


