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

search contexts: backend for setting as default and starring#44624

Merged
limitedmage merged 21 commits into
mainfrom
jp/contextsstarreddefault
Dec 5, 2022
Merged

search contexts: backend for setting as default and starring#44624
limitedmage merged 21 commits into
mainfrom
jp/contextsstarreddefault

Conversation

@limitedmage

@limitedmage limitedmage commented Nov 18, 2022

Copy link
Copy Markdown
Contributor

Part of #44903

This adds the backend code needed for allowing users to set a context as their default or starring a context. This does not yet have any changes to the behavior (eg. sort order or how default contexts will work).

Test plan

Updated existing tests to pass and made sure all the Go database tests pass with the new schema.

Not sure what other tests I should add here; this is relatively straightforward CRUD stuff. Any suggestions are appreciated.

@cla-bot cla-bot Bot added the cla-signed label Nov 18, 2022
@sg-e2e-regression-test-bob

sg-e2e-regression-test-bob commented Nov 18, 2022

Copy link
Copy Markdown

Bundle size report 📦

Initial size Total size Async size Modules
-0.02% (-0.65 kb) 0.02% (+2.87 kb) 0.03% (+3.52 kb) 0.00% (0)

Look at the Statoscope report for a full comparison between the commits d69cf06 and 1b52d29 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

@limitedmage limitedmage marked this pull request as ready for review November 19, 2022 00:25
@limitedmage limitedmage requested review from a team, camdencheek and novoselrok November 19, 2022 00:25
@sourcegraph-bot

sourcegraph-bot commented Nov 19, 2022

Copy link
Copy Markdown
Contributor

Codenotify: Notifying subscribers in CODENOTIFY files for diff 1b52d29...d69cf06.

Notify File(s)
@beyang internal/search/searchcontexts/search_contexts.go
internal/search/searchcontexts/search_contexts_test.go
@camdencheek internal/search/searchcontexts/search_contexts.go
internal/search/searchcontexts/search_contexts_test.go
@fkling client/search-ui/src/input/SearchBox.story.tsx
client/search-ui/src/input/SearchContextDropdown.test.tsx
client/search-ui/src/input/SearchContextDropdown.tsx
client/search-ui/src/input/SearchContextMenu.story.tsx
client/search-ui/src/input/SearchContextMenu.test.tsx
client/search-ui/src/input/SearchContextMenu.tsx
client/search-ui/src/input/snapshots/SearchContextMenu.test.tsx.snap
client/search/src/backend.ts
client/search/src/index.ts
client/web/src/search/home/SearchPage.story.tsx
client/web/src/search/home/SearchPage.test.tsx
@keegancsmith cmd/frontend/graphqlbackend/search_contexts.go
internal/search/searchcontexts/search_contexts.go
internal/search/searchcontexts/search_contexts_test.go
@philipp-spiess client/jetbrains/webview/src/search/App.tsx
client/jetbrains/webview/src/search/input/JetBrainsSearchBox.story.tsx
client/jetbrains/webview/src/search/input/JetBrainsSearchBox.tsx
@rvantonder cmd/frontend/graphqlbackend/search_contexts.go
@vdavid client/jetbrains/webview/src/search/App.tsx
client/jetbrains/webview/src/search/input/JetBrainsSearchBox.story.tsx
client/jetbrains/webview/src/search/input/JetBrainsSearchBox.tsx

Comment thread cmd/frontend/graphqlbackend/search_contexts.graphql Outdated
Comment thread internal/database/search_contexts.go
…rmal query (#44875)

* search contexts: remove autodefined contexts from frontend, add to normal query

* generate

* remove real global context, use union with dummy row instead

* fix some tests

* fix CountSearchContexts

* add test for CountSearchContexts

* search contexts: order contexts list by default first, then starred, then others (#44876)

* search contexts: order contexts list by default first, then starred, then others

* generate mocks

* Add test for new order

* explicit select and remove unused scan var

* simplify getting authenticated user

* fix go lint
@limitedmage

Copy link
Copy Markdown
Contributor Author

@novoselrok @camdencheek I've merged the stacked PRs #44875 and #44876 into this and added some tests, can you take a quick second look? Thanks!

@camdencheek camdencheek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A few comments, nothing blocking

Comment thread internal/database/search_contexts.go
Comment thread internal/database/search_contexts.go Outdated
LEFT JOIN search_context_stars scs
ON scs.user_id = %d AND scs.search_context_id = sc.id
LEFT JOIN search_context_default scd
ON scd.user_id = %d AND scd.search_context_id = sc.id

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This turned out pretty clean!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes! Thank you!! Are there still any perf implications from so many joins?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There definitely are, but these are joins on primary keys, so I'm not concerned by it. Nothing to worry about unless we see perf issues.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sounds great, thanks!

Comment thread internal/search/searchcontexts/search_contexts.go
Comment thread internal/search/searchcontexts/search_contexts.go Outdated
Comment thread migrations/frontend/squashed.sql Outdated
Comment thread migrations/frontend/1668813365_create_search_contexts_stars_defaults/up.sql Outdated
Comment thread migrations/frontend/1668813365_create_search_contexts_stars_defaults/up.sql Outdated
* search contexts: update header

* add back tab

* fix spacing

* fix action button width
* search contexts: update header

* search contexts: table view in management page

* add menu

* fix build failure

* add back tab

* fix spacing

* fix action button width

* address minor issues from figma

* search contexts: card view for mobile (#45040)

* search contexts: card view for mobile

* fix build failure

* give up on sr-only mixin
@limitedmage limitedmage merged commit ff6f03a into main Dec 5, 2022
@limitedmage limitedmage deleted the jp/contextsstarreddefault branch December 5, 2022 19:22
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.

5 participants