mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: alphabetize template list (#3363)
This commit is contained in:
@@ -897,8 +897,8 @@ func (q *fakeQuerier) GetTemplatesWithFilter(_ context.Context, arg database.Get
|
||||
}
|
||||
if len(templates) > 0 {
|
||||
slices.SortFunc(templates, func(i, j database.Template) bool {
|
||||
if !i.CreatedAt.Before(j.CreatedAt) {
|
||||
return false
|
||||
if i.Name != j.Name {
|
||||
return i.Name < j.Name
|
||||
}
|
||||
return i.ID.String() < j.ID.String()
|
||||
})
|
||||
@@ -1080,8 +1080,8 @@ func (q *fakeQuerier) GetTemplates(_ context.Context) ([]database.Template, erro
|
||||
|
||||
templates := slices.Clone(q.templates)
|
||||
slices.SortFunc(templates, func(i, j database.Template) bool {
|
||||
if !i.CreatedAt.Before(j.CreatedAt) {
|
||||
return false
|
||||
if i.Name != j.Name {
|
||||
return i.Name < j.Name
|
||||
}
|
||||
return i.ID.String() < j.ID.String()
|
||||
})
|
||||
|
||||
@@ -1889,7 +1889,7 @@ func (q *sqlQuerier) GetTemplateByOrganizationAndName(ctx context.Context, arg G
|
||||
|
||||
const getTemplates = `-- name: GetTemplates :many
|
||||
SELECT id, created_at, updated_at, organization_id, deleted, name, provisioner, active_version_id, description, max_ttl, min_autostart_interval, created_by FROM templates
|
||||
ORDER BY (created_at, id) ASC
|
||||
ORDER BY (name, id) ASC
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) GetTemplates(ctx context.Context) ([]Template, error) {
|
||||
@@ -1954,7 +1954,7 @@ WHERE
|
||||
id = ANY($4)
|
||||
ELSE true
|
||||
END
|
||||
ORDER BY (created_at, id) ASC
|
||||
ORDER BY (name, id) ASC
|
||||
`
|
||||
|
||||
type GetTemplatesWithFilterParams struct {
|
||||
|
||||
@@ -34,7 +34,7 @@ WHERE
|
||||
id = ANY(@ids)
|
||||
ELSE true
|
||||
END
|
||||
ORDER BY (created_at, id) ASC
|
||||
ORDER BY (name, id) ASC
|
||||
;
|
||||
|
||||
-- name: GetTemplateByOrganizationAndName :one
|
||||
@@ -51,7 +51,7 @@ LIMIT
|
||||
|
||||
-- name: GetTemplates :many
|
||||
SELECT * FROM templates
|
||||
ORDER BY (created_at, id) ASC
|
||||
ORDER BY (name, id) ASC
|
||||
;
|
||||
|
||||
-- name: InsertTemplate :one
|
||||
|
||||
Reference in New Issue
Block a user