-
Notifications
You must be signed in to change notification settings - Fork 899
feat: add user-level parameter autofill #11731
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
Changes from 16 commits
efeb85e
71bc50d
73594f9
9bbc251
d11fb58
1c70e36
2b0783f
1a28ef2
1569223
2d544d8
93deee5
51cc138
e61491b
1a1d0fa
6cb0e29
76e0018
e4ad149
4b00f45
69ed7c0
5417e09
72f1e88
b0eece8
ba18f20
a6db979
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3758,6 +3758,42 @@ func (q *FakeQuerier) GetUserLinksByUserID(_ context.Context, userID uuid.UUID) | |
return uls, nil | ||
} | ||
|
||
func (q *FakeQuerier) GetUserWorkspaceBuildParameters(_ context.Context, ownerID uuid.UUID) ([]database.GetUserWorkspaceBuildParametersRow, error) { | ||
q.mutex.RLock() | ||
defer q.mutex.RUnlock() | ||
|
||
userWorkspaceIDs := make(map[uuid.UUID]struct{}) | ||
for _, ws := range q.workspaces { | ||
if ws.OwnerID != ownerID { | ||
continue | ||
} | ||
userWorkspaceIDs[ws.ID] = struct{}{} | ||
} | ||
|
||
userWorkspaceBuilds := make(map[uuid.UUID]database.WorkspaceBuildTable) | ||
for _, wb := range q.workspaceBuilds { | ||
if _, ok := userWorkspaceIDs[wb.WorkspaceID]; !ok { | ||
continue | ||
} | ||
userWorkspaceBuilds[wb.ID] = wb | ||
} | ||
|
||
userWorkspaceBuildParameters := make([]database.GetUserWorkspaceBuildParametersRow, 0) | ||
for _, wbp := range q.workspaceBuildParameters { | ||
wb, ok := userWorkspaceBuilds[wbp.WorkspaceBuildID] | ||
if !ok { | ||
continue | ||
} | ||
userWorkspaceBuildParameters = append(userWorkspaceBuildParameters, database.GetUserWorkspaceBuildParametersRow{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this returns every build parameter for every user, and also includes a named parameter multiple times if there are multiple builds. You need to match the join and filtering behavior of the SQL query There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I second this comment. SQL query and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Built out the unit test a little bit in the interest of getting this wrapped up today. |
||
Name: wbp.Name, | ||
Value: wbp.Value, | ||
CreatedAt: wb.CreatedAt, | ||
}) | ||
} | ||
|
||
return userWorkspaceBuildParameters, nil | ||
} | ||
|
||
func (q *FakeQuerier) GetUsers(_ context.Context, params database.GetUsersParams) ([]database.GetUsersRow, error) { | ||
if err := validateDatabaseType(params); err != nil { | ||
return nil, err | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,28 @@ FROM | |
workspace_build_parameters | ||
WHERE | ||
workspace_build_id = $1; | ||
|
||
-- name: GetUserWorkspaceBuildParameters :many | ||
SELECT | ||
sub.name, | ||
sub.value, | ||
sub.created_at | ||
FROM ( | ||
SELECT | ||
wbp.name, | ||
wbp.value, | ||
wb.created_at, | ||
ROW_NUMBER() OVER (PARTITION BY wbp.name ORDER BY wb.created_at DESC) as rn | ||
ammario marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking loud - maybe we should extend
depending on database behavior, the engine can mix order, which is usually the source of flakiness in our tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to select all data, instead we could remove the partition and simply do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not going to address right now in the interest of haste. It's unclear how useful this feature will be in its current form. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suspect that @mafredri suggested a simpler, more performant query. |
||
FROM | ||
workspace_build_parameters wbp | ||
JOIN | ||
workspace_builds wb ON wb.id = wbp.workspace_build_id | ||
JOIN | ||
workspaces w ON w.id = wb.workspace_id | ||
WHERE | ||
w.owner_id = $1 | ||
ammario marked this conversation as resolved.
Show resolved
Hide resolved
|
||
AND wb.transition = 'start' | ||
ammario marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) sub | ||
WHERE | ||
sub.rn = 1 | ||
LIMIT 100; | ||
ammario marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.