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

Commitee92a76

Browse files
committed
feat(coderd/database): add ListTasks query
1 parent3d779c2 commitee92a76

File tree

7 files changed

+95
-0
lines changed

7 files changed

+95
-0
lines changed

‎coderd/database/dbauthz/dbauthz.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4485,6 +4485,11 @@ func (q *querier) ListProvisionerKeysByOrganizationExcludeReserved(ctx context.C
44854485
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.ListProvisionerKeysByOrganizationExcludeReserved)(ctx,organizationID)
44864486
}
44874487

4488+
func (q*querier)ListTasks(ctx context.Context,arg database.ListTasksParams) ([]database.Task,error) {
4489+
// TODO(Cian): replace this with a sql filter for improved performance.
4490+
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.ListTasks)(ctx,arg)
4491+
}
4492+
44884493
func (q*querier)ListUserSecrets(ctx context.Context,userID uuid.UUID) ([]database.UserSecret,error) {
44894494
obj:=rbac.ResourceUserSecret.WithOwner(userID.String())
44904495
iferr:=q.authorizeContext(ctx,policy.ActionRead,obj);err!=nil {

‎coderd/database/dbauthz/dbauthz_test.go‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,6 +2392,18 @@ func (s *MethodTestSuite) TestTasks() {
23922392
dbm.EXPECT().GetTaskByWorkspaceID(gomock.Any(),task.WorkspaceID.UUID).Return(task,nil).AnyTimes()
23932393
check.Args(task.WorkspaceID.UUID).Asserts(task,policy.ActionRead).Returns(task)
23942394
}))
2395+
s.Run("ListTasks",s.Mocked(func(dbm*dbmock.MockStore,faker*gofakeit.Faker,check*expects) {
2396+
u1:=testutil.Fake(s.T(),faker, database.User{})
2397+
u2:=testutil.Fake(s.T(),faker, database.User{})
2398+
org1:=testutil.Fake(s.T(),faker, database.Organization{})
2399+
org2:=testutil.Fake(s.T(),faker, database.Organization{})
2400+
_=testutil.Fake(s.T(),faker, database.OrganizationMember{UserID:u1.ID,OrganizationID:org1.ID})
2401+
_=testutil.Fake(s.T(),faker, database.OrganizationMember{UserID:u2.ID,OrganizationID:org2.ID})
2402+
t1:=testutil.Fake(s.T(),faker, database.Task{OwnerID:u1.ID})
2403+
t2:=testutil.Fake(s.T(),faker, database.Task{OwnerID:u2.ID})
2404+
dbm.EXPECT().ListTasks(gomock.Any(),gomock.Any()).Return([]database.Task{t1,t2},nil).AnyTimes()
2405+
check.Args(database.ListTasksParams{}).Asserts(t1,policy.ActionRead,t2,policy.ActionRead).Returns([]database.Task{t1,t2})
2406+
}))
23952407
}
23962408

23972409
func (s*MethodTestSuite)TestProvisionerKeys() {

‎coderd/database/dbmetrics/querymetrics.go‎

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

‎coderd/database/dbmock/dbmock.go‎

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

‎coderd/database/querier.go‎

Lines changed: 1 addition & 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: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/tasks.sql‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,10 @@ SELECT * FROM tasks_with_status WHERE id = @id::uuid;
2121

2222
-- name: GetTaskByWorkspaceID :one
2323
SELECT*FROM tasks_with_statusWHERE workspace_id= @workspace_id::uuid;
24+
25+
-- name: ListTasks :many
26+
SELECT*FROM tasks_with_status tws
27+
WHEREtws.deleted_at ISNULL
28+
AND CASE WHEN @owner_id::UUIDIS NOT NULL THENtws.owner_id= @owner_id::UUID ELSE TRUE END
29+
AND CASE WHEN @organization_id::UUIDIS NOT NULL THENtws.organization_id= @organization_id::UUID ELSE TRUE END
30+
ORDER BYtws.created_atDESC;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp