mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
chore: join owner, template, and org in new workspace view (#15116)
Joins in fields like `username`, `avatar_url`, `organization_name`, `template_name` to `workspaces` via a **view**. The view must be maintained moving forward, but this prevents needing to add RBAC permissions to fetch related workspace fields.
This commit is contained in:
@@ -55,6 +55,17 @@ func Contains[T comparable](haystack []T, needle T) bool {
|
||||
})
|
||||
}
|
||||
|
||||
// Find returns the first element that satisfies the condition.
|
||||
func Find[T any](haystack []T, cond func(T) bool) (T, bool) {
|
||||
for _, hay := range haystack {
|
||||
if cond(hay) {
|
||||
return hay, true
|
||||
}
|
||||
}
|
||||
var empty T
|
||||
return empty, false
|
||||
}
|
||||
|
||||
// Overlap returns if the 2 sets have any overlap (element(s) in common)
|
||||
func Overlap[T comparable](a []T, b []T) bool {
|
||||
return OverlapCompare(a, b, func(a, b T) bool {
|
||||
|
||||
Reference in New Issue
Block a user