Skip to content

fix(chart-list): sort by changed_on instead of last_saved_at#39984

Open
massucattoj wants to merge 4 commits into
apache:masterfrom
massucattoj:fix/chart-list-last-modified-sort
Open

fix(chart-list): sort by changed_on instead of last_saved_at#39984
massucattoj wants to merge 4 commits into
apache:masterfrom
massucattoj:fix/chart-list-last-modified-sort

Conversation

@massucattoj
Copy link
Copy Markdown
Contributor

SUMMARY

The "Last modified" column on the chart list page (/chart/list/) was sorting incorrectly because the displayed value and the sort key referenced different fields:

  • Displayed: changed_on_delta_humanized (derived from changed_on, the row's last write timestamp — always populated)
  • Sorted by: last_saved_at (a separate nullable field that only updates on an explicit user save via the explore PUT endpoint)

Charts with NULL last_saved_at (never saved by a user) or with divergent last_saved_at/changed_on appeared out of order, since the visible humanized date didn't match the underlying sort key.

This change aligns the column's accessor/id with the displayed value (changed_on_delta_humanized), matching the existing pattern in DashboardList and SavedQueryList. The backend already supports ordering by changed_on_delta_humanized via the @renders("changed_on") decorator in superset/models/helpers.py, so it correctly sorts by the underlying changed_on datetime column.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:
Screenshot 2026-05-08 at 22 29 26

After:
Screenshot 2026-05-08 at 22 29 42

TESTING INSTRUCTIONS

To reproduce, you need charts with divergent changed_on and last_saved_at values (a fresh seed will not show the bug since both columns are populated identically at insert time).

  1. Connect to the metadata DB and create divergence:
UPDATE slices SET changed_on = NOW() - INTERVAL '2 years'         WHERE id % 4 = 0;
UPDATE slices SET changed_on = NOW() - INTERVAL '1 year 6 months' WHERE id % 4 = 1;
UPDATE slices SET changed_on = NOW() - INTERVAL '8 months'        WHERE id % 4 = 2;
UPDATE slices SET changed_on = NOW() - INTERVAL '3 months'        WHERE id % 4 = 3;

UPDATE slices SET last_saved_at = NOW() - INTERVAL '3 months'        WHERE id % 4 = 0;
UPDATE slices SET last_saved_at = NOW() - INTERVAL '2 years'         WHERE id % 4 = 1;
UPDATE slices SET last_saved_at = NOW() - INTERVAL '1 year 6 months' WHERE id % 4 = 2;
UPDATE slices SET last_saved_at = NOW() - INTERVAL '8 months'        WHERE id % 4 = 3;
UPDATE slices SET last_saved_at = NULL WHERE id % 11 = 0;
  1. Navigate to /chart/list/.
  2. Click the Last modified column header to sort.
  3. Toggle ASC/DESC and page through the results.
  4. Verify the humanized timestamps appear in monotonic order (no "2 years ago" sandwiched between recent entries, no "7 months ago" appearing among older blocks).

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 9, 2026

Code Review Agent Run #7b28b9

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 925eb9e..925eb9e
    • superset-frontend/src/pages/ChartList/ChartList.listview.test.tsx
    • superset-frontend/src/pages/ChartList/index.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot Bot added the listview Namespace | Anything related to lists, such as Dashboards, Charts, Datasets, etc. label May 9, 2026
Comment thread superset-frontend/src/pages/ChartList/ChartList.listview.test.tsx
@bito-code-review
Copy link
Copy Markdown
Contributor

The flagged issue is correct - the test now fails because the initial page load already sorts by 'changed_on_delta_humanized', so clicking the header creates a second matching request. To fix this, change the assertion to check the latest call instead of expecting exactly one call.

superset-frontend/src/pages/ChartList/ChartList.listview.test.tsx

const lastModifiedSortCalls = dataCalls
        .filter(
          call =>
            call.url.includes('order_column') &&
            call.url.includes('changed_on_delta_humanized'),
        );
      const lastCall = lastModifiedSortCalls[lastModifiedSortCalls.length - 1];
      expect(lastCall.url).toContain('order_column=changed_on_delta_humanized');

@codecov
Copy link
Copy Markdown

codecov Bot commented May 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.20%. Comparing base (965ec47) to head (6f231c0).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #39984   +/-   ##
=======================================
  Coverage   64.20%   64.20%           
=======================================
  Files        2592     2592           
  Lines      139232   139232           
  Branches    32327    32327           
=======================================
  Hits        89389    89389           
  Misses      48308    48308           
  Partials     1535     1535           
Flag Coverage Δ
javascript 67.33% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread superset-frontend/src/pages/ChartList/ChartList.listview.test.tsx Outdated
@massucattoj massucattoj requested a review from rusackas May 23, 2026 16:38
@netlify
Copy link
Copy Markdown

netlify Bot commented May 23, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit d6c8067
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a11d7ff85be2a00087faf76
😎 Deploy Preview https://deploy-preview-39984--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 23, 2026

Code Review Agent Run #a9ef52

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 925eb9e..7cb3157
    • superset-frontend/src/pages/ChartList/ChartList.listview.test.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@netlify
Copy link
Copy Markdown

netlify Bot commented May 23, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 6f231c0
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a1211fcb5697600082644f5
😎 Deploy Preview https://deploy-preview-39984--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

listview Namespace | Anything related to lists, such as Dashboards, Charts, Datasets, etc. size/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants