Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in chartPivot() / tablePivot() when using timeDimension "last 24 hours" #361

Closed
0is1 opened this issue Jan 31, 2020 · 1 comment
Closed
Labels
bug Something isn't working
Milestone

Comments

@0is1
Copy link

0is1 commented Jan 31, 2020

Describe the bug
With query something like this:

{
"limit":10000,
"measures":["XXX.count"],
"timeDimensions":[{
  "dimension":"XXX.createdat",
  "granularity":"hour",
  "dateRange":"last 24 hours"}
]}

It seems that resultSet.loadResponse.data includes correct data (only "hourly" hits that have count > 0) but resultSet.chartPivot() returns data based on dateRange and granularity?

So in this case because granularity is hour and and dateRange is "between two days" => there will be 48 items in chartPivot / tablePivot data.

To Reproduce
Steps to reproduce the behavior:

  1. Use query that is something like described above
  2. Compare resultSet.loadResponse.data to resultSet.chartPivot() / resultSet.tablePivot()
  3. resultSet.loadResponse.data should include only data that is created within 24 hours and count > 0
  4. resultSet.chartPivot() / resultSet.tablePivot() return data that seems to follow the pattern HOURS_PER_DAY * DAYS_IN_DATE_RANGE => in this case 24 * 2 = 48

Expected behavior
resultSet.chartPivot() / resultSet.tablePivot() should return only data from within the date range (in this case there should be 24 items in the result)

Screenshots
resultSets

Version:

"@cubejs-client/core": "^0.15.2",
"@cubejs-client/react": "^0.15.0",

Additional context
Slack conversation https://cube-js.slack.com/archives/CC0403RRR/p1580200363166700

@paveltiunov
Copy link
Member

paveltiunov commented Feb 1, 2020

@0is1 Hey Janne! Thanks for posting this! I believe it can be single line fix here: https://github.com/cube-js/cube.js/blob/2783446dbd7739412377309a34d68da02739a25b/packages/cubejs-client-core/src/ResultSet.js#L174
Adding hour should fix this I believe.

@paveltiunov paveltiunov added the bug Something isn't working label Feb 1, 2020
@paveltiunov paveltiunov added this to the v0.17.0 milestone Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants