fix(plugin-chart-handlebars): order by control not work (#21005)

This commit is contained in:
Stephen Liu
2022-08-22 15:00:34 +08:00
committed by GitHub
parent 7c0963f6ae
commit e70699fb43
3 changed files with 16 additions and 5 deletions

View File

@@ -16,15 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
import { buildQueryContext, QueryFormData } from '@superset-ui/core';
import {
buildQueryContext,
normalizeOrderBy,
QueryFormData,
} from '@superset-ui/core';
export default function buildQuery(formData: QueryFormData) {
const { metric, sort_by_metric, groupby } = formData;
const { groupby } = formData;
return buildQueryContext(formData, baseQueryObject => [
{
...baseQueryObject,
...(sort_by_metric && { orderby: [[metric, false]] }),
orderby: normalizeOrderBy(baseQueryObject).orderby,
...(groupby && { groupby }),
},
]);