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

Commitc12bc39

Browse files
authored
fix: always show a newly created workspace at the top of the list (#6984)
Fixes#5795.
1 parent46f42ea commitc12bc39

File tree

6 files changed

+14
-9
lines changed

6 files changed

+14
-9
lines changed

‎coderd/database/dbfake/databasefake.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3361,6 +3361,7 @@ func (q *fakeQuerier) InsertWorkspace(_ context.Context, arg database.InsertWork
33613361
Name:arg.Name,
33623362
AutostartSchedule:arg.AutostartSchedule,
33633363
Ttl:arg.Ttl,
3364+
LastUsedAt:arg.LastUsedAt,
33643365
}
33653366
q.workspaces=append(q.workspaces,workspace)
33663367
returnworkspace,nil

‎coderd/database/dbgen/generator.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ func Workspace(t testing.TB, db database.Store, orig database.Workspace) databas
145145
UpdatedAt:takeFirst(orig.UpdatedAt,database.Now()),
146146
OrganizationID:takeFirst(orig.OrganizationID,uuid.New()),
147147
TemplateID:takeFirst(orig.TemplateID,uuid.New()),
148+
LastUsedAt:takeFirst(orig.LastUsedAt,database.Now()),
148149
Name:takeFirst(orig.Name,namesgenerator.GetRandomName(1)),
149150
AutostartSchedule:orig.AutostartSchedule,
150151
Ttl:orig.Ttl,

‎coderd/database/queries.sql.go‎

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

‎coderd/database/queries/workspaces.sql‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,11 @@ INSERT INTO
270270
template_id,
271271
name,
272272
autostart_schedule,
273-
ttl
273+
ttl,
274+
last_used_at
274275
)
275276
VALUES
276-
($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING*;
277+
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING*;
277278

278279
-- name: UpdateWorkspaceDeletedByID :exec
279280
UPDATE

‎coderd/insights_test.go‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,9 @@ func TestDeploymentInsights(t *testing.T) {
5858
daus,err:=client.DeploymentDAUs(context.Background())
5959
require.NoError(t,err)
6060

61-
require.Equal(t,&codersdk.DeploymentDAUsResponse{
62-
Entries: []codersdk.DAUEntry{},
63-
},daus,"no DAUs when stats are empty")
64-
6561
res,err:=client.Workspaces(ctx, codersdk.WorkspaceFilter{})
6662
require.NoError(t,err)
67-
assert.Zero(t,res.Workspaces[0].LastUsedAt)
63+
assert.NotZero(t,res.Workspaces[0].LastUsedAt)
6864

6965
conn,err:=client.DialWorkspaceAgent(ctx,resources[0].Agents[0].ID,&codersdk.DialWorkspaceAgentOptions{
7066
Logger:slogtest.Make(t,nil).Named("tailnet"),

‎coderd/workspaces.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,9 @@ func (api *API) postWorkspacesByOrganization(rw http.ResponseWriter, r *http.Req
480480
Name:createWorkspace.Name,
481481
AutostartSchedule:dbAutostartSchedule,
482482
Ttl:dbTTL,
483+
// The workspaces page will sort by last used at, and it's useful to
484+
// have the newly created workspace at the top of the list!
485+
LastUsedAt:database.Now(),
483486
})
484487
iferr!=nil {
485488
returnxerrors.Errorf("insert workspace: %w",err)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp