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

Commitd7a0abf

Browse files
committed
chore: rename template_with_user to template_with_names
1 parent48f2ecf commitd7a0abf

File tree

8 files changed

+38
-27
lines changed

8 files changed

+38
-27
lines changed

‎cli/templatelist.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
func (r*RootCmd)templateList()*serpent.Command {
1414
orgContext:=NewOrganizationContext()
1515
formatter:=cliui.NewOutputFormatter(
16-
cliui.TableFormat([]templateTableRow{}, []string{"name","last updated","used by"}),
16+
cliui.TableFormat([]templateTableRow{}, []string{"name","organization name","last updated","used by"}),
1717
cliui.JSONFormat(),
1818
)
1919

‎coderd/database/dbmem/dbmem.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ func (q *FakeQuerier) getLatestWorkspaceBuildByWorkspaceIDNoLock(_ context.Conte
515515
func (q*FakeQuerier)getTemplateByIDNoLock(_ context.Context,id uuid.UUID) (database.Template,error) {
516516
for_,template:=rangeq.templates {
517517
iftemplate.ID==id {
518-
returnq.templateWithUserNoLock(template),nil
518+
returnq.templateWithNameNoLock(template),nil
519519
}
520520
}
521521
return database.Template{},sql.ErrNoRows
@@ -524,26 +524,36 @@ func (q *FakeQuerier) getTemplateByIDNoLock(_ context.Context, id uuid.UUID) (da
524524
func (q*FakeQuerier)templatesWithUserNoLock(tpl []database.TemplateTable) []database.Template {
525525
cpy:=make([]database.Template,0,len(tpl))
526526
for_,t:=rangetpl {
527-
cpy=append(cpy,q.templateWithUserNoLock(t))
527+
cpy=append(cpy,q.templateWithNameNoLock(t))
528528
}
529529
returncpy
530530
}
531531

532-
func (q*FakeQuerier)templateWithUserNoLock(tpl database.TemplateTable) database.Template {
532+
func (q*FakeQuerier)templateWithNameNoLock(tpl database.TemplateTable) database.Template {
533533
varuser database.User
534534
for_,_user:=rangeq.users {
535535
if_user.ID==tpl.CreatedBy {
536536
user=_user
537537
break
538538
}
539539
}
540-
varwithUser database.Template
540+
541+
varorg database.Organization
542+
for_,_org:=rangeq.organizations {
543+
if_org.ID==tpl.OrganizationID {
544+
org=_org
545+
break
546+
}
547+
}
548+
549+
varwithNames database.Template
541550
// This is a cheeky way to copy the fields over without explicitly listing them all.
542551
d,_:=json.Marshal(tpl)
543-
_=json.Unmarshal(d,&withUser)
544-
withUser.CreatedByUsername=user.Username
545-
withUser.CreatedByAvatarURL=user.AvatarURL
546-
returnwithUser
552+
_=json.Unmarshal(d,&withNames)
553+
withNames.CreatedByUsername=user.Username
554+
withNames.CreatedByAvatarURL=user.AvatarURL
555+
withNames.OrganizationName=org.Name
556+
returnwithNames
547557
}
548558

549559
func (q*FakeQuerier)templateVersionWithUserNoLock(tpl database.TemplateVersionTable) database.TemplateVersion {
@@ -3675,7 +3685,7 @@ func (q *FakeQuerier) GetTemplateByOrganizationAndName(_ context.Context, arg da
36753685
iftemplate.Deleted!=arg.Deleted {
36763686
continue
36773687
}
3678-
returnq.templateWithUserNoLock(template),nil
3688+
returnq.templateWithNameNoLock(template),nil
36793689
}
36803690
return database.Template{},sql.ErrNoRows
36813691
}
@@ -9323,7 +9333,7 @@ func (q *FakeQuerier) GetAuthorizedTemplates(ctx context.Context, arg database.G
93239333

93249334
vartemplates []database.Template
93259335
for_,templateTable:=rangeq.templates {
9326-
template:=q.templateWithUserNoLock(templateTable)
9336+
template:=q.templateWithNameNoLock(templateTable)
93279337
ifprepared!=nil&&prepared.Authorize(ctx,template.RBACObject())!=nil {
93289338
continue
93299339
}

‎coderd/database/dump.sql

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

‎coderd/database/gentest/models_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestViewSubsetTemplate(t *testing.T) {
3232
tableFields:=allFields(table)
3333
joinedFields:=allFields(joined)
3434
if!assert.Subset(t,fieldNames(joinedFields),fieldNames(tableFields),"table is not subset") {
35-
t.Log("Some fields were added to the Template Table without updating the 'template_with_users' view.")
35+
t.Log("Some fields were added to the Template Table without updating the 'template_with_names' view.")
3636
t.Log("See migration 000138_join_users.up.sql to create the view.")
3737
}
3838
}

‎coderd/database/migrations/000222_template_organization_name.up.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
-- Update the template_with_users view by recreating it.
22
DROPVIEW template_with_users;
33

4+
-- Renaming template_with_users -> template_with_names
45
CREATE VIEW
5-
template_with_users
6+
template_with_names
67
AS
78
SELECT
89
templates.*,
@@ -20,4 +21,4 @@ FROM
2021
ONtemplates.organization_id=organizations.id
2122
;
2223

23-
COMMENT ON VIEWtemplate_with_users IS'Joins in the display name information such as username, avatar, and organization name.';
24+
COMMENT ON VIEWtemplate_with_names IS'Joins in the display name information such as username, avatar, and organization name.';

‎coderd/database/queries.sql.go

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

‎coderd/database/queries/templates.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
SELECT
33
*
44
FROM
5-
template_with_users
5+
template_with_names
66
WHERE
77
id= $1
88
LIMIT
@@ -12,7 +12,7 @@ LIMIT
1212
SELECT
1313
*
1414
FROM
15-
template_with_usersAS templates
15+
template_with_namesAS templates
1616
WHERE
1717
-- Optionally include deleted templates
1818
templates.deleted= @deleted
@@ -54,7 +54,7 @@ ORDER BY (name, id) ASC
5454
SELECT
5555
*
5656
FROM
57-
template_with_usersAS templates
57+
template_with_namesAS templates
5858
WHERE
5959
organization_id= @organization_id
6060
AND deleted= @deleted
@@ -63,7 +63,7 @@ LIMIT
6363
1;
6464

6565
-- name: GetTemplates :many
66-
SELECT*FROMtemplate_with_usersAS templates
66+
SELECT*FROMtemplate_with_namesAS templates
6767
ORDER BY (name, id)ASC
6868
;
6969

‎coderd/database/sqlc.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ sql:
5555
-column:"templates.group_acl"
5656
go_type:
5757
type:"TemplateACL"
58-
-column:"template_with_users.user_acl"
58+
-column:"template_with_names.user_acl"
5959
go_type:
6060
type:"TemplateACL"
61-
-column:"template_with_users.group_acl"
61+
-column:"template_with_names.group_acl"
6262
go_type:
6363
type:"TemplateACL"
6464
-column:"template_usage_stats.app_usage_mins"
@@ -72,7 +72,7 @@ sql:
7272
type:"[]byte"
7373
rename:
7474
template:TemplateTable
75-
template_with_user:Template
75+
template_with_name:Template
7676
workspace_build:WorkspaceBuildTable
7777
workspace_build_with_user:WorkspaceBuild
7878
template_version:TemplateVersionTable

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp