Skip to content

Commit 670237b

Browse files
committed
feat(api-gateway): Order support
1 parent b962e80 commit 670237b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/cubejs-api-gateway/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ const querySchema = Joi.object().keys({
117117
Joi.string()
118118
]
119119
})),
120+
order: Joi.object().pattern(id, Joi.valid('asc', 'desc')),
120121
segments: Joi.array().items(id),
121122
timezone: Joi.string(),
122123
limit: Joi.number().integer().min(1).max(50000)
@@ -165,10 +166,15 @@ const normalizeQuery = (query) => {
165166
granularity: d.split('.')[2]
166167
}));
167168
const timezone = query.timezone || 'UTC';
169+
const order = query.order && Object.keys(query.order).map(k => ({
170+
id: k,
171+
desc: query.order[k] === 'desc'
172+
}));
168173
return {
169174
...query,
170175
rowLimit: query.rowLimit || query.limit,
171176
timezone,
177+
order,
172178
dimensions: (query.dimensions || []).filter(d => d.split('.').length !== 3),
173179
timeDimensions: (query.timeDimensions || []).map(td => {
174180
let dateRange;

0 commit comments

Comments
 (0)