Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc674128

Browse files
authored
chore: allow search by build params in workspace search filter (#12694)
* chore: workspace search filter allow search by params* has_param will return all workspaces with the param existance* exact matching
1 parentb4fd819 commitc674128

File tree

10 files changed

+485
-47
lines changed

10 files changed

+485
-47
lines changed

‎coderd/database/dbmem/dbmem.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8739,6 +8739,55 @@ func (q *FakeQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg database.
87398739
continue
87408740
}
87418741

8742+
iflen(arg.HasParam)>0||len(arg.ParamNames)>0 {
8743+
build,err:=q.getLatestWorkspaceBuildByWorkspaceIDNoLock(ctx,workspace.ID)
8744+
iferr!=nil {
8745+
returnnil,xerrors.Errorf("get latest build: %w",err)
8746+
}
8747+
8748+
params:=make([]database.WorkspaceBuildParameter,0)
8749+
for_,param:=rangeq.workspaceBuildParameters {
8750+
ifparam.WorkspaceBuildID!=build.ID {
8751+
continue
8752+
}
8753+
params=append(params,param)
8754+
}
8755+
8756+
varinnerErrerror
8757+
index:=slices.IndexFunc(params,func(buildParam database.WorkspaceBuildParameter)bool {
8758+
// If hasParam matches, then we are done. This is a good match.
8759+
ifslices.ContainsFunc(arg.HasParam,func(namestring)bool {
8760+
returnstrings.EqualFold(buildParam.Name,name)
8761+
}) {
8762+
returntrue
8763+
}
8764+
8765+
// Check name + value
8766+
match:=false
8767+
fori:=rangearg.ParamNames {
8768+
matchName:=arg.ParamNames[i]
8769+
if!strings.EqualFold(matchName,buildParam.Name) {
8770+
continue
8771+
}
8772+
8773+
matchValue:=arg.ParamValues[i]
8774+
if!strings.EqualFold(matchValue,buildParam.Value) {
8775+
continue
8776+
}
8777+
match=true
8778+
break
8779+
}
8780+
8781+
returnmatch
8782+
})
8783+
ifinnerErr!=nil {
8784+
returnnil,xerrors.Errorf("error searching workspace build params: %w",innerErr)
8785+
}
8786+
ifindex<0 {
8787+
continue
8788+
}
8789+
}
8790+
87428791
ifarg.OwnerUsername!="" {
87438792
owner,err:=q.getUserByIDNoLock(workspace.OwnerID)
87448793
iferr==nil&&!strings.EqualFold(arg.OwnerUsername,owner.Username) {

‎coderd/database/modelqueries.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,12 @@ func (q *sqlQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg GetWorkspa
213213
// The name comment is for metric tracking
214214
query:=fmt.Sprintf("-- name: GetAuthorizedWorkspaces :many\n%s",filtered)
215215
rows,err:=q.db.QueryContext(ctx,query,
216+
pq.Array(arg.ParamNames),
217+
pq.Array(arg.ParamValues),
216218
arg.Deleted,
217219
arg.Status,
218220
arg.OwnerID,
221+
pq.Array(arg.HasParam),
219222
arg.OwnerUsername,
220223
arg.TemplateName,
221224
pq.Array(arg.TemplateIDs),

‎coderd/database/querier.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries.sql.go

Lines changed: 89 additions & 39 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp