Skip to content

Conversation

@dmiska25
Copy link
Contributor

@dmiska25 dmiska25 commented Dec 6, 2025

Problem

Currently, when duplicating dashboards, filter selections and other configuration settings are not included. This is inconvenient if there are many filters and the duplicate dashboard only needs a few changes.

Changes

Added logic to duplicate dashboard filters, variables, breakdown_colors, and data_color_theme_id along with the dashboard unless those values were included with the request. If explicit values are provided in the request, they override the source dashboard values.

Also refactored existing_dashboard variable initialization for clarity per PR feedback.

How did you test this code?

Added 9 automated tests to ensure all fields are copied correctly from the existing dashboard record to the duplicate, and that explicit values override source values. Also, ran all existing automated tests with no regressions.

@dmiska25 dmiska25 force-pushed the fix/dashboard-filter-duplication branch from 9140336 to a62a07f Compare December 6, 2025 23:20
@dmiska25 dmiska25 marked this pull request as ready for review December 6, 2025 23:22
Copilot AI review requested due to automatic review settings December 6, 2025 23:22
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
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

This PR adds functionality to copy dashboard filters when duplicating a dashboard, addressing the inconvenience of manually setting many filters on a duplicate. The implementation fetches filters from the source dashboard unless explicitly overridden in the request.

Key Changes:

  • Modified dashboard duplication logic to copy filters from the source dashboard by default
  • Added conditional logic to allow explicit filter override when provided in the request
  • Refactored existing_dashboard fetching to occur earlier in the create flow for reuse

Reviewed changes

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

File Description
posthog/api/dashboards/dashboard.py Implements filter copying logic by fetching the source dashboard earlier and copying its filters when duplicating, unless explicit filters are provided in the request
posthog/api/test/dashboards/test_dashboard.py Adds two test cases to verify filters are copied during duplication and that explicit filters override source filters

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vdekrijger vdekrijger requested a review from a team December 7, 2025 07:15
dmiska25 added a commit to dmiska25/posthog that referenced this pull request Dec 13, 2025
dmiska25 added a commit to dmiska25/posthog that referenced this pull request Dec 13, 2025
…wn_colors, and data_color_theme_id during dashboard duplication
@dmiska25 dmiska25 force-pushed the fix/dashboard-filter-duplication branch from a62a07f to c93161b Compare December 13, 2025 20:41
@dmiska25 dmiska25 changed the title fix(dashboards): copy filters when duplicating dashboards fix(dashboards): copy filters, variables, breakdown_colors, and data_color_theme_id when duplicating dashboards Dec 13, 2025
@vdekrijger
Copy link
Contributor

Would you also please be able to fix the linter errors 🙏 ?

Additionally, I think that merging master will help resolve some of the failing CI jobs as from a few spotchecks they did not appear to be related to your changes!

@dmiska25 dmiska25 force-pushed the fix/dashboard-filter-duplication branch from c93161b to 49007e8 Compare December 15, 2025 15:16
dmiska25 added a commit to dmiska25/posthog that referenced this pull request Dec 15, 2025
dmiska25 added a commit to dmiska25/posthog that referenced this pull request Dec 15, 2025
…wn_colors, and data_color_theme_id during dashboard duplication
@dmiska25 dmiska25 force-pushed the fix/dashboard-filter-duplication branch from 49007e8 to 8da2e81 Compare December 15, 2025 15:17
Copy link
Contributor

@vdekrijger vdekrijger left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

@vdekrijger vdekrijger merged commit 8078ecb into PostHog:master Dec 18, 2025
149 checks passed
odin-posthog pushed a commit that referenced this pull request Dec 18, 2025
@dmiska25 dmiska25 deleted the fix/dashboard-filter-duplication branch December 18, 2025 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants