-
Notifications
You must be signed in to change notification settings - Fork 887
feat: workspace filter query supported in backend #2232
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
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
1a14a8c
feat: add support for template in workspace filter
f0ssel e3bd559
get working
f0ssel 91d7d84
make gen
f0ssel 2941b58
feat: Implement workspace search filter to support names
Emyrk 70f4304
Use new query param parser for pagination fields
Emyrk 0f7bb21
Fix fake db implementation
Emyrk 5687dbe
Add unit test for parsing query params
Emyrk 18e5247
Fix linting
Emyrk 9a1b182
Fix search
Emyrk fab5d8c
Maintain old behavior
Emyrk 15754c5
Linting
Emyrk f3123fe
Merge remote-tracking branch 'origin/main' into stevenmasley/workspac…
Emyrk d1c6319
Remove excessive calls, use filters on a single query
Emyrk e5ec365
Remove unused code
Emyrk 21683d2
Add unit test to keep fake db clean
Emyrk fc48397
Fix typo
Emyrk 5310164
Drop like name search on template
Emyrk c64ed18
Fix linting
Emyrk c6e3a57
Move WorkspaceSearchQuery to workspaces.go
Emyrk 7821aa4
Search all templates with name
Emyrk d3091f0
Add more complex filter unit test
Emyrk ebcb831
Fix unit test to not violate pg constraint
Emyrk 9368c48
Drop owner_id from query params
Emyrk b5f5705
Remove unused code/params
Emyrk 9c9a5e2
Merge remote-tracking branch 'origin/main' into stevenmasley/workspac…
Emyrk 4512a9b
Remove field from ts
Emyrk e9e913d
Address PR comments
Emyrk 2aac32b
Fix js test
Emyrk c8813cc
Fix unit test
Emyrk ee35935
PR feedback
Emyrk 4ad585e
Rename vague function name
Emyrk 6251493
WorkspaceSearchQuery now returns db filter
Emyrk ac8dddd
Correct unit test and typescript
Emyrk 727239e
Merge remote-tracking branch 'origin/main' into stevenmasley/workspac…
Emyrk 92dcbc8
fmt
Emyrk 0a51e02
Use !== over !=
Emyrk 5a1272c
Fix js unit test
Emyrk 5b5039b
Js linting
Emyrk 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 hidden or 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 hidden or 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,61 @@ | ||
package databasefake_test | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/coder/coder/coderd/database" | ||
|
||
"github.com/coder/coder/coderd/database/databasefake" | ||
) | ||
|
||
// TestExactMethods will ensure the fake database does not hold onto excessive | ||
// functions. The fake database is a manual implementation, so it is possible | ||
// we forget to delete functions that we remove. This unit test just ensures | ||
// we remove the extra methods. | ||
func TestExactMethods(t *testing.T) { | ||
t.Parallel() | ||
|
||
// extraFakeMethods contains the extra allowed methods that are not a part | ||
// of the database.Store interface. | ||
extraFakeMethods := map[string]string{ | ||
// Example | ||
// "SortFakeLists": "Helper function used", | ||
} | ||
|
||
fake := reflect.TypeOf(databasefake.New()) | ||
fakeMethods := methods(fake) | ||
|
||
store := reflect.TypeOf((*database.Store)(nil)).Elem() | ||
storeMethods := methods(store) | ||
|
||
// Store should be a subset | ||
for k := range storeMethods { | ||
_, ok := fakeMethods[k] | ||
if !ok { | ||
panic(fmt.Sprintf("This should never happen. FakeDB missing method %s, so doesn't fit the interface", k)) | ||
} | ||
delete(storeMethods, k) | ||
delete(fakeMethods, k) | ||
} | ||
|
||
for k := range fakeMethods { | ||
_, ok := extraFakeMethods[k] | ||
if ok { | ||
continue | ||
} | ||
// If you are seeing this error, you have an extra function not required | ||
// for the database.Store. If you still want to keep it, add it to | ||
// 'extraFakeMethods' to allow it. | ||
t.Errorf("Fake method '%s()' is excessive and not needed to fit interface, delete it", k) | ||
} | ||
} | ||
|
||
func methods(rt reflect.Type) map[string]bool { | ||
methods := make(map[string]bool) | ||
for i := 0; i < rt.NumMethod(); i++ { | ||
methods[rt.Method(i).Name] = true | ||
} | ||
return methods | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
This helps find which methods are not required on the fake. Just good for keeping that struct clean.