Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

insights: improve update insight flow #44769

Merged
leonore merged 11 commits into
mainfrom
leo/unnecessary-update-step
Nov 24, 2022
Merged

insights: improve update insight flow #44769
leonore merged 11 commits into
mainfrom
leo/unnecessary-update-step

Conversation

@leonore

@leonore leonore commented Nov 23, 2022

Copy link
Copy Markdown
Contributor

part of #42116

previously, in the update insight mutation for existing insight series we

  1. remove the existing series from the view (this soft-deletes the series)
  2. create a new series and attach it to the view (this does a new attach series to view step)
  3. update the insight view to be attached to the old series

call 3 was completely redundant as the series was no longer in use. it would just affect 0 rows each time.

now, we check whether the series existed before. if it didn't we just create a new one. otherwise we check what has changed. if it's only presentation metadata we won't trigger an insight recalculation.

Test plan

Added an integration test and manually validated that before/after did not change when creating some insights

see it in action: https://www.loom.com/share/2b893d3691cd40df81a910e60bd42ab5

with sg start enterprise-codeinsights running:

go test -long -run TestUpdateInsight -base-url "https://sourcegraph.test:3443" -v

2022/11/23 17:29:56 Site admin authenticated: gqltest-admin
=== RUN   TestUpdateInsight
--- PASS: TestUpdateInsight (1.37s)
PASS
ok  	github.com/sourcegraph/sourcegraph/dev/gqltest	2.014s

@leonore leonore requested a review from a team November 23, 2022 17:35
@cla-bot cla-bot Bot added the cla-signed label Nov 23, 2022
@sourcegraph-bot

sourcegraph-bot commented Nov 23, 2022

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff b4c9f4d...76b981c.

Notify File(s)
@sourcegraph/code-insights-backend enterprise/internal/insights/resolvers/insight_view_resolvers.go
@unknwon dev/gqltest/code_insights_test.go
internal/gqltestutil/code_insights.go

@leonore leonore changed the title insights: remove redundant UpdateViewSeries call insights: improve update insight flow Nov 23, 2022
Comment thread enterprise/internal/insights/resolvers/insight_view_resolvers.go
Comment thread enterprise/internal/insights/resolvers/insight_view_resolvers.go
@leonore leonore enabled auto-merge (squash) November 24, 2022 11:08
@leonore leonore merged commit 5612fe1 into main Nov 24, 2022
@leonore leonore deleted the leo/unnecessary-update-step branch November 24, 2022 11:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants