Skip to content

Commit

Permalink
feat(api-gateway): Order support
Browse files Browse the repository at this point in the history
  • Loading branch information
paveltiunov committed Apr 12, 2019
1 parent b962e80 commit 670237b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/cubejs-api-gateway/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const querySchema = Joi.object().keys({
Joi.string()
]
})),
order: Joi.object().pattern(id, Joi.valid('asc', 'desc')),
segments: Joi.array().items(id),
timezone: Joi.string(),
limit: Joi.number().integer().min(1).max(50000)
Expand Down Expand Up @@ -165,10 +166,15 @@ const normalizeQuery = (query) => {
granularity: d.split('.')[2]
}));
const timezone = query.timezone || 'UTC';
const order = query.order && Object.keys(query.order).map(k => ({
id: k,
desc: query.order[k] === 'desc'
}));
return {
...query,
rowLimit: query.rowLimit || query.limit,
timezone,
order,
dimensions: (query.dimensions || []).filter(d => d.split('.').length !== 3),
timeDimensions: (query.timeDimensions || []).map(td => {
let dateRange;
Expand Down

0 comments on commit 670237b

Please sign in to comment.