-
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b328227
refactor(insights): use query based insights for duplication
thmsobrmlr fd8f25c
types
thmsobrmlr 6eb897a
more types
thmsobrmlr b6a7486
move api wrapper
thmsobrmlr 2027c9d
use getInsightFilterOrQueryForPersistance in save actions
thmsobrmlr 6637349
fix tests
thmsobrmlr ef953e4
Update UI snapshots for `chromium` (2)
github-actions[bot] c60a282
use legacyInsight for deleteWithUndo
thmsobrmlr 017d84d
implement in insightsModel
thmsobrmlr f85360d
fix connect
thmsobrmlr d0b46e4
fix
thmsobrmlr 430c9ae
read as query for insights model
thmsobrmlr b3afc6c
refactor(insights): query based `renameInsight` (#23471)
thmsobrmlr 3722315
Merge branch 'master' into duplicate-query-based-insight
thmsobrmlr 96fa443
Update UI snapshots for `chromium` (2)
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import api from 'lib/api' | ||
|
||
import { getInsightFilterOrQueryForPersistance } from '~/queries/nodes/InsightQuery/utils/queryNodeToFilter' | ||
import { getQueryBasedInsightModel } from '~/queries/nodes/InsightViz/utils' | ||
import { InsightModel, QueryBasedInsightModel } from '~/types' | ||
|
||
type ReturnedInsightModelByFlag<Flag extends boolean> = Flag extends true ? QueryBasedInsightModel : InsightModel | ||
|
||
export const insightsApi = { | ||
async create<Flag extends boolean>( | ||
insight: QueryBasedInsightModel, | ||
options: { | ||
writeAsQuery: boolean | ||
readAsQuery: Flag | ||
} | ||
): Promise<ReturnedInsightModelByFlag<Flag>> { | ||
const data = { | ||
...insight, | ||
...getInsightFilterOrQueryForPersistance(insight, options.writeAsQuery), | ||
} | ||
const legacyInsight: InsightModel = await api.insights.create(data) | ||
return ( | ||
options.readAsQuery ? getQueryBasedInsightModel(legacyInsight) : legacyInsight | ||
) as ReturnedInsightModelByFlag<Flag> | ||
}, | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.