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

Commit06acc27

Browse files
committed
refactor(dbmem): improve deprecation filtering logic with a helper function and improve comments by adding the matching SQL logic
1 parent12985c5 commit06acc27

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

‎coderd/database/dbmem/dbmem.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,12 @@ func (q *FakeQuerier) getProvisionerJobsByIDsWithQueuePositionLockedGlobalQueue(
13801380
returnjobs,nil
13811381
}
13821382

1383+
// isDeprecated returns true if the template is deprecated.
1384+
// A template is considered deprecated when it has a deprecation message.
1385+
funcisDeprecated(template database.Template)bool {
1386+
returntemplate.Deprecated!=""
1387+
}
1388+
13831389
func (*FakeQuerier)AcquireLock(_ context.Context,_int64)error {
13841390
returnxerrors.New("AcquireLock must only be called within a transaction")
13851391
}
@@ -13021,8 +13027,17 @@ func (q *FakeQuerier) GetAuthorizedTemplates(ctx context.Context, arg database.G
1302113027
ifarg.ExactName!=""&&!strings.EqualFold(template.Name,arg.ExactName) {
1302213028
continue
1302313029
}
13024-
// Check if the search query filter 'Deprecated' status matches the template's 'Deprecated' status
13025-
ifarg.Deprecated.Valid&&arg.Deprecated.Bool!= (template.Deprecated!="") {
13030+
// Filters templates based on the search query filter 'Deprecated' status
13031+
// Matching SQL logic:
13032+
// -- Filter by deprecated
13033+
// AND CASE
13034+
// WHEN :deprecated IS NOT NULL THEN
13035+
// CASE
13036+
// WHEN :deprecated THEN deprecated != ''
13037+
// ELSE deprecated = ''
13038+
// END
13039+
// ELSE true
13040+
ifarg.Deprecated.Valid&&arg.Deprecated.Bool!=isDeprecated(template) {
1302613041
continue
1302713042
}
1302813043
ifarg.FuzzyName!="" {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp