ktmud commented on a change in pull request #13057:
URL: https://github.com/apache/superset/pull/13057#discussion_r574203535



##########
File path: superset/viz.py
##########
@@ -865,6 +865,12 @@ def query_obj(self) -> QueryObjectDict:
             raise QueryObjectValidationError(_("Please choose at least one 
metric"))
         if set(groupby) & set(columns):
             raise QueryObjectValidationError(_("Group By' and 'Columns' can't 
overlap"))
+        sort_by = self.form_data.get("timeseries_limit_metric")
+        if sort_by:
+            sort_by_label = utils.get_metric_name(sort_by)
+            if sort_by_label not in d["metrics"]:
+                d["metrics"].append(sort_by)
+            d["orderby"] = [(sort_by, not self.form_data.get("order_desc", 
True))]

Review comment:
       This is incorrect. The second parameter in the `orderby` tuple is 
"is_ascending", which is the opposite meaning of `order_desc`. However, we also 
want the default to be order in descending in case `order_desc` is not set.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to