-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(insights): query based duplicateInsight
#23435
Conversation
b94faf7
to
acae7df
Compare
acae7df
to
a52762c
Compare
84f1b6c
to
2027c9d
Compare
|
||
type ReturnedInsightModelByFlag<Flag extends boolean> = Flag extends true ? QueryBasedInsightModel : InsightModel | ||
|
||
export const insightsApi = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially did the handling in lib/api.ts
, but that doesn't work as (1) it's included in the toolbar and importing anything there explodes size (2) doing so breaks kea, likely due to some logics needing to be mounted in the right order. Therefore this wrapper.
Size Change: +134 B (+0.01%) Total Size: 1.07 MB ℹ️ View Unchanged
|
sourceInsight.name = '' | ||
sourceInsight.derived_name = 'should be copied' | ||
await logic.asyncActions.duplicateInsight(sourceInsight) | ||
expect(api.create).toHaveBeenCalledWith( | ||
`api/projects/${MOCK_TEAM_ID}/insights`, | ||
expect.objectContaining({ name: '' }) | ||
expect.objectContaining({ name: '' }), | ||
expect.objectContaining({}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ApiRequest.create
is implemented like this:
return await api.create(this.assembleFullUrl(), options?.data, options)
Meaning the data gets repeated in options. I didn't want to change the implementation in this PR, therefore adjusting tests.
📸 UI snapshots have been updated1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
Triggered by this commit. |
duplicateInsight
# Conflicts: # frontend/__snapshots__/scenes-app-insights--funnel-top-to-bottom-breakdown--dark.png # frontend/src/scenes/saved-insights/SavedInsights.tsx
📸 UI snapshots have been updated1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
Triggered by this commit. |
This reverts commit 307a783.
Problem
We want to have only query based insights frontend side, but we still need to send them to the backend with
filters
. The bigger goal of the coming PRs is to adapt all instances where we send insights to the backend for persistance with a wrapper function, so that the frontend can happily live with query based insights only.Changes
This PR lets all instances of
duplicateInsight
take a query based insight and conditionally:filters
orquery
to the backend, based on a feature flagfilters
orquery
, based on a boolean value -> work is in progress to set this totrue
everywhereHow did you test this code?
With flag disabled:
With flag enabled: