- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.9k
 
feat(cubejs-client-core): add custom granularities support to drilldown() #10094
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
base: master
Are you sure you want to change the base?
feat(cubejs-client-core): add custom granularities support to drilldown() #10094
Conversation
| 
               | 
          ||
| if (granularity !== undefined) { | ||
| const range = dayRange(value, value).snapTo(granularity); | ||
| let range: { start: dayjs.Dayjs; end: dayjs.Dayjs }; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that we need to tweak the dayRange function and pass timeDimensionAnnotation, because it's used in time-series, and without that, custom time dimension logic will not work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
friendly ping to @vasilev-alex for advices here :)
…dez/cube into drill-down-custom-granularities
| 
           @ovr You are absolutely right! 😉 , I moved the logic to snapTo func, and also Im using now the annotations.  | 
    
| // If custom granularity has an origin, align to it | ||
| if (customGranularity.origin) { | ||
| let origin = internalDayjs(customGranularity.origin); | ||
| if (customGranularity.offset) { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
offset and origin are mutually exclusive
| 
               | 
          ||
| while (start.startOf(value).isBefore(end) || start.isSame(end)) { | ||
| results.push(start); | ||
| start = start.add(1, value); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would this work for custom intervals like 3 days or 2 days 3 hours 4 minutes?
Check List
Changes Made:
- Created a test case that replicates scenario with a 5-minute custom granularity
- The test verifies that drilling down returns the correct interval range
- Modified the snapTo() method to detect custom granularities using isPredefinedGranularity()
- For custom granularities:
- Predefined granularities continue to use the existing snapTo() logic