File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
packages/cubejs-api-gateway/src Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -1171,6 +1171,7 @@ class ApiGateway {
11711171 let queryType : QueryType = QueryTypeEnum . REGULAR_QUERY ;
11721172 if ( ! Array . isArray ( query ) ) {
11731173 query = this . compareDateRangeTransformer ( query ) ;
1174+ query = this . fillMissingDateRangesForTimeDimensions ( query ) ;
11741175 if ( Array . isArray ( query ) ) {
11751176 queryType = QueryTypeEnum . COMPARE_DATE_RANGE_QUERY ;
11761177 }
@@ -2485,6 +2486,28 @@ class ApiGateway {
24852486 }
24862487 } ;
24872488
2489+ protected fillMissingDateRangesForTimeDimensions ( query ) {
2490+ if ( ! query . timeDimensions ) {
2491+ return query ;
2492+ }
2493+
2494+ const timeDimensionCount = query . timeDimensions . reduce ( ( acc , item ) => {
2495+ acc [ item . dimension ] = acc [ item . dimension ] || { } ;
2496+ if ( ! acc [ item . dimension ] . dateRange && item . dateRange ) {
2497+ acc [ item . dimension ] . dateRange = item . dateRange ;
2498+ }
2499+ return acc ;
2500+ } , { } ) ;
2501+
2502+ query . timeDimensions . forEach ( td => {
2503+ if ( ! td . dateRange && timeDimensionCount [ td . dimension ] . dateRange ) {
2504+ td . dateRange = timeDimensionCount [ td . dimension ] . dateRange ;
2505+ }
2506+ } ) ;
2507+
2508+ return query ;
2509+ }
2510+
24882511 protected compareDateRangeTransformer ( query ) {
24892512 let queryCompareDateRange ;
24902513 let compareDateRangeTDIndex ;
You can’t perform that action at this time.
0 commit comments