rusackas commented on code in PR #40231:
URL: https://github.com/apache/superset/pull/40231#discussion_r3262507546
##########
tests/integration_tests/charts/api_tests.py:
##########
@@ -1237,6 +1237,69 @@ def test_get_charts_tag_filters(self):
chart["id"] for chart in data_by_name["result"]
), set(chart.id for chart in expected_charts) # noqa: C401
+ def test_get_charts_changed_on_delta_humanized_sort_monotonic(self):
+ """Regression for #27500: sorting the chart list by
+ `changed_on_delta_humanized` desc must yield results whose underlying
+ `changed_on` timestamps are monotonically non-increasing. The original
+ report shows the humanized column visually out of order, suggesting
+ the sort key didn't actually reflect the timestamp."""
+ from datetime import datetime, timedelta
+
+ admin = self.get_user("admin")
+ # Insert two charts with distinct changed_on timestamps. Use raw UPDATE
+ # to force the values since assignment alone can be overridden by the
+ # before-update hook.
+ chart_older = self.insert_chart(
+ "regression_27500_older", [admin.id], 1, description="z"
+ )
+ chart_newer = self.insert_chart(
+ "regression_27500_newer", [admin.id], 1, description="z"
+ )
+ now = datetime.utcnow()
+ chart_older.changed_on = now - timedelta(days=2)
+ chart_newer.changed_on = now
Review Comment:
Good intuition — fixed in ce5d1222. Note: your specific pair (`10 days ago`
vs `2 days ago`) doesn't actually discriminate, since `'2' > '1'` lexically
agrees with timestamp-desc. I went with `3 hours ago` vs `5 hours ago` instead
— lexical desc puts `"5..."` first while timestamp desc must put `"3..."`
first, so a regression to string-based sorting would now flip the result.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]