groupdate: Missing Some Records
hi, @ankane , thanks for your amazing work.
I think i MIGHT have found a bug, but I cant understand it quite well…
Im using 4.0.2 and when I group a collection and sum it, the last sum remains wrong (0 i think)
For example:
r = RealEstate.where.not(published_at: nil); r.count
D, [2018-11-03T00:11:49.104738 #29] DEBUG -- : (4.9ms) SELECT COUNT(*) FROM "real_estates" WHERE ("real_estates"."published_at" IS NOT NULL)
=> 717
Then I group it:
r.group_by_month('real_estates.published_at', range: Date.parse('01/01/2014')..(Time.now+1.month)).count.map{|k,v| v}.sum
D, [2018-11-03T00:08:11.100646 #29] DEBUG -- : (4.9ms) SELECT COUNT(*) AS count_all, (DATE_TRUNC('month', (real_estates.published_at::timestamptz) AT TIME ZONE 'America/Sao_Paulo')) AT TIME ZONE 'America/Sao_Paulo' AS date_trunc_month_real_estates_published_at_timestamptz_at_time_ FROM "real_estates" WHERE ("real_estates"."published_at" IS NOT NULL) AND (real_estates.published_at >= '2014-01-01 02:00:00' AND real_estates.published_at <= '2018-12-04 02:08:11') GROUP BY (DATE_TRUNC('month', (real_estates.published_at::timestamptz) AT TIME ZONE 'America/Sao_Paulo')) AT TIME ZONE 'America/Sao_Paulo'
=> 711
It happens the same way without the range attribute.
do you have any idea of what’s wrong or maybe Im missing something?
rails 5.1.2 ruby 2.4.1
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 26 (10 by maintainers)
Just had the same issue and fixed it by following Heroku instructions suggested by @Hamdan85.
To illustrate, it is november and my graphs were showing data only up until october.
In four simple steps, you can:
1. Create a follower database
To create a follower database you can use the heroku web interface. Just go to your app and, inside Resources tab, click on your database. Go to the “Durability” tab, scroll all the way down to the “followers” session and click “Create Follower”. Select the most appropriate plan and you’re done.
2. Set maintenance mode to on
Back to your app, go to Settings, scroll down, and set maintenance mode to on.
3. Promote your new database
This is the first step I had to use the terminal. So I ran
heroku pg:info --app touts-production
to check the name of the newly created database. Then finally promoted it withheroku pg:promote HEROKU_POSTGRESQL_ROSE_URL --app touts-production
.4. Turn off maintenance mode
You can now set your app back to normal with
heroku maintenance:off --app touts-production
.And now I can finally see the current month:
Thanks, @ankane, btw, for the awesome contributions to the community!
Thanks. I’m not sure what you’re proposing, but if you find a better way to do it, feel free to submit a PR.
Email Heroku about it.