Timezone issue displaying time-based graphs

Expected behavior

When Forest displays a time-based graph (e.g. Total New customers by day) the graph is rendered correctly.

Actual behavior

The graph is not rendered correctly and an error icon is shown in its place instead.

This happens when the timezone set in the Forest project settings (which is submitted to the server to generate the graph data) differs from what the Rails app/database is using.

To reproduce it in the development environment, I’ve also created data for the graph: before, just before, on, just after and after the UK daylight savings date.

Failure Logs

  /app/vendor/bundle/ruby/3.0.0/gems/groupdate-5.2.2/lib/groupdate/series_builder.rb:50:in `block in generate'
  /app/vendor/bundle/ruby/3.0.0/gems/groupdate-5.2.2/lib/groupdate/series_builder.rb:35:in `each'
  /app/vendor/bundle/ruby/3.0.0/gems/groupdate-5.2.2/lib/groupdate/series_builder.rb:35:in `generate'
  /app/vendor/bundle/ruby/3.0.0/gems/groupdate-5.2.2/lib/groupdate/magic.rb:133:in `perform'
  /app/vendor/bundle/ruby/3.0.0/gems/groupdate-5.2.2/lib/groupdate/magic.rb:219:in `block in process_result'
  /app/vendor/bundle/ruby/3.0.0/gems/groupdate-5.2.2/lib/groupdate/magic.rb:218:in `each'
  /app/vendor/bundle/ruby/3.0.0/gems/groupdate-5.2.2/lib/groupdate/magic.rb:218:in `process_result'
  /app/vendor/bundle/ruby/3.0.0/gems/groupdate-5.2.2/lib/groupdate.rb:31:in `process_result'
  /app/vendor/bundle/ruby/3.0.0/gems/groupdate-5.2.2/lib/groupdate/relation.rb:13:in `calculate'
  /app/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.3.2/lib/active_record/relation/calculations.rb:51:in `count'
  /app/vendor/bundle/ruby/3.0.0/gems/forest_liana-6.3.7/app/services/forest_liana/line_stat_getter.rb:36:in `perform'
  /app/vendor/bundle/ruby/3.0.0/gems/forest_liana-6.3.7/app/controllers/forest_liana/stats_controller.rb:41:in `get'

Context

Please provide any relevant information about your setup.

  • Package Version: 6.3.7
  • Ruby version: 3.0.1
  • Rails version: 6.1.3.2
  • Database Dialect: Postgresql
  • Database Version: 13
  • Project Name: Back Office

Hello @sergior,

I’m able to reproduce but it’s a bug from groupdate gem. Here is the important log you missed.

Groupdate::Error (Database and Ruby have inconsistent time zone info. Database returned 2021-05-11 19:00:00 -0300):

I found the two related issues in the groupdate repository.

I’m not sure how can we fix this on our side. I will let a colleague take over on this thread.

Best regards,
Morgan

I’m aware the issue is raised by the groupdate gem (as the stacktrace shows) but that’s a Forest dependency to display the graphs and the current behaviour is the users that are trying to see these time based graphs are not being able to do so.

Hello @sergior,

For helping you, I’d like to know if the collection you use, Customer I guess, has relations with other tables?

Thank you,

Hi @Guillaume_Cisco ,

The customer has indeed relations with other tables.

The issue experienced happens even when only using customer attributes as filters to display the time-based graph (in the example I gave, it’s only using the customer’s created_at).

Hello @sergior,

We have just released a new version of forest-rails.
Could you try with the 6.4.1 one?

Let me know if it fixes your issue :slight_smile:

1 Like

Hi @Guillaume_Cisco , sorry for the late reply.

I’ve tested the version 6.4.1 and it seems that it did indeed fix the issue. Thank you for all the help!

2 Likes