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

web: use stream search results for export#45702

Merged
taras-yemets merged 9 commits intomainfrom
taras-yemets/fix-results-export
Dec 16, 2022
Merged

web: use stream search results for export#45702
taras-yemets merged 9 commits intomainfrom
taras-yemets/fix-results-export

Conversation

@taras-yemets
Copy link
Contributor

@taras-yemets taras-yemets commented Dec 15, 2022

Closes https://github.com/sourcegraph/sourcegraph/issues/45718

Uses stream search results for export.

Previously we were using two different approaches for search results page and for search results export.
The search results page uses stream search results and the search export called the GraphQL API (this approach migrated from sourcegraph-search-export extension). This caused inconsistencies in what users see on the results page and what results they download after clicking the 'Export results' button.

This PR:

Test plan

CI passes.

App preview:

Check out the client app preview documentation to learn more.

@cla-bot cla-bot bot added the cla-signed label Dec 15, 2022
@sourcegraph-bot
Copy link
Contributor

sourcegraph-bot commented Dec 15, 2022

Codenotify: Notifying subscribers in CODENOTIFY files for diff 3ba7222...65a311a.

Notify File(s)
@fkling client/web/src/search/results/SearchActionsMenu.tsx
client/web/src/search/results/SearchResultsInfoBar.test.tsx
client/web/src/search/results/SearchResultsInfoBar.tsx
client/web/src/search/results/StreamingSearchResults.tsx
client/web/src/search/results/searchResultsExport.test.ts
client/web/src/search/results/searchResultsExport.ts
client/web/src/search/results/useExportSearchResultsQuery.ts
@limitedmage client/web/src/search/results/SearchActionsMenu.tsx
client/web/src/search/results/SearchResultsInfoBar.test.tsx
client/web/src/search/results/SearchResultsInfoBar.tsx
client/web/src/search/results/StreamingSearchResults.tsx
client/web/src/search/results/searchResultsExport.test.ts
client/web/src/search/results/searchResultsExport.ts
client/web/src/search/results/useExportSearchResultsQuery.ts

@sg-e2e-regression-test-bob
Copy link

sg-e2e-regression-test-bob commented Dec 15, 2022

Bundle size report 📦

Initial size Total size Async size Modules
0.00% (0.00 kb) -0.00% (-0.65 kb) -0.01% (-0.65 kb) 0.00% (0)

Look at the Statoscope report for a full comparison between the commits 65a311a and 3ba7222 or learn more.

Open explanation
  • Initial size is the size of the initial bundle (the one that is loaded when you open the page)
  • Total size is the size of the initial bundle + all the async loaded chunks
  • Async size is the size of all the async loaded chunks
  • Modules is the number of modules in the initial bundle

Copy link
Contributor

@philipp-spiess philipp-spiess left a comment

Choose a reason for hiding this comment

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

Niiceee!

query={submittedURLQuery}
enableCodeInsights={codeInsightsEnabled && isCodeInsightsEnabled(props.settingsCascade)}
enableCodeMonitoring={enableCodeMonitoring}
resultsFound={resultsFound}
Copy link
Contributor

Choose a reason for hiding this comment

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

Lol we had the results here already haha 😶‍🌫️

@philipp-spiess
Copy link
Contributor

@taras-yemets I think we should add a change log entry as well, wdyt? I think in general I’m not adding that often enough 😓 but especially for customer reported issues it would be good to include it if they ever need to find out which version they have to update to.

@jasonhawkharris
Copy link
Contributor

@taras-yemets I think we should add a change log entry as well, wdyt? I think in general I’m not adding that often enough 😓 but especially for customer reported issues it would be good to include it if they ever need to find out which version they have to update to.

100% agree with a change log entry here. Otherwise LGTM! Thanks for getting it done so quickly!

@taras-yemets taras-yemets merged commit 0f49f9a into main Dec 16, 2022
@taras-yemets taras-yemets deleted the taras-yemets/fix-results-export branch December 16, 2022 16:45
Comment on lines -53 to +57
const [requestSearchResultsExport] = useExportSearchResultsQuery({ query, patternType, sourcegraphURL })
const resultsFound = results ? results.results.length > 0 : false
const downloadResults = useCallback(
() => (results ? downloadSearchResults(results, sourcegraphURL, query) : undefined),
[results, sourcegraphURL, query]
)
Copy link
Member

Choose a reason for hiding this comment

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

pinging a 3 month old PR, yay. But I think this is the root cause of a regression. There is a concept of display limit the streaming search API uses. Basically we only return 1500 results down to the browser (but continue streaming accurate result counts). Which means if you just use the results already downloaded to display you won't actually export all results. Here is were we hardcode that https://sourcegraph.com/github.com/sourcegraph/sourcegraph@db2922509bf00cd14fb30393a12d863974c15e88/-/blob/client/shared/src/search/stream.ts?L490

Here is the slack thread that just got started about this https://sourcegraph.slack.com/archives/CHEKCRWKV/p1678300443530819

Pinging here so hopefully one of the experts on this PR can turn around a fix :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replied in the referenced thread

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.

Inconsistent search export results

6 participants