mikebridge opened a new pull request, #43837:
URL: https://github.com/apache/superset/pull/43837

   ### SUMMARY
   
   A dashboard's version-history related items should include a member chart's 
edits **only while that chart was attached** to the dashboard. In practice, a 
chart edit made **after** the chart was removed from the dashboard still 
surfaced as a `Chart updated` related entry — under both "All changes" and 
"Related items only".
   
   **Root cause** 
(`superset/versioning/activity/queries.py::charts_attached_to_dashboard`): each 
attachment window was derived from the `dashboard_slices_version` shadow's 
`transaction_id` / `end_transaction_id`, with `operation_type = 2` (DELETE) 
rows excluded as "phantom detachment rows". But sqlalchemy-continuum **never 
closes an association shadow row's `end_transaction_id`** — its unit-of-work 
only *inserts* association versions (`create_association_versions`); the 
validity backfill that sets `end_transaction_id` runs for parent objects, not 
for M2M links. So the attach (INSERT) row's `end_transaction_id` stays `NULL` 
for the association's entire life, every derived window was open-ended 
`[attach_tx, None)`, and the DELETE row that actually carries the detach 
transaction was exactly the row being discarded. Result: any edit of a chart 
that was *ever* on the dashboard fell inside the (open) window.
   
   **Fix**: pair the INSERT/DELETE rows. A new pure `_attachment_windows` 
helper walks the shadow rows per slice in transaction order — opening a window 
at each INSERT and closing it at the next DELETE's `transaction_id` (open-ended 
while the chart is still attached; no window at all when a chart is added and 
removed in the same save, which never reached a committed dashboard state). 
`charts_attached_to_dashboard` now fetches `operation_type` and delegates the 
windowing. Downstream scope-resolution, intersection, and union are unchanged.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Backend-only. Before: with chart X attached at t1, edited at t2, removed at 
t3, edited again at t4, the dashboard's related history showed the t4 edit. 
After: the window is `[t1, t3)`, so the t2 edit (while attached) is included 
and the t4 edit (after removal) is excluded.
   
   ### TESTING INSTRUCTIONS
   
   `pytest tests/unit_tests/versioning/test_activity.py -k attachment_windows` 
— covers the after-removal exclusion (the ticket's oracle: an INSERT@t1 / 
DELETE@t3 pair excludes an edit at t4), a still-attached open window, reattach 
cycles, row-order independence, add-and-remove-in-one-save, and per-slice 
separation.
   
   Manual: put a chart on a dashboard, edit it (save), remove it from the 
dashboard (save), edit it again (save); open the dashboard's version history — 
only the edit made while the chart was on the dashboard appears as a related 
`Chart updated`.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] 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
   


-- 
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]

Reply via email to