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

Commitfe1e8b5

Browse files
committed
add owner id
1 parent5d8ca26 commitfe1e8b5

File tree

8 files changed

+43
-24
lines changed

8 files changed

+43
-24
lines changed

‎coderd/database/dbmem/dbmem.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11152,11 +11152,12 @@ func (q *FakeQuerier) GetAuthorizedWorkspacesAndAgents(ctx context.Context, prep
1115211152
}
1115311153

1115411154
out=append(out, database.GetWorkspacesAndAgentsRow{
11155-
WorkspaceID:w.ID,
11156-
WorkspaceName:w.Name,
11157-
JobStatus:job.JobStatus,
11158-
Transition:build.Transition,
11159-
Agents:outAgents,
11155+
ID:w.ID,
11156+
Name:w.Name,
11157+
OwnerID:w.OwnerID,
11158+
JobStatus:job.JobStatus,
11159+
Transition:build.Transition,
11160+
Agents:outAgents,
1116011161
})
1116111162
}
1116211163

‎coderd/database/modelqueries.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,9 @@ func (q *sqlQuerier) GetAuthorizedWorkspacesAndAgents(ctx context.Context, prepa
333333
forrows.Next() {
334334
variGetWorkspacesAndAgentsRow
335335
iferr:=rows.Scan(
336-
&i.WorkspaceID,
337-
&i.WorkspaceName,
336+
&i.ID,
337+
&i.Name,
338+
&i.OwnerID,
338339
&i.JobStatus,
339340
&i.Transition,
340341
pq.Array(&i.Agents),

‎coderd/database/querier_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ func TestGetAuthorizedWorkspacesAndAgents(t *testing.T) {
689689
require.NoError(t,err)
690690
require.Len(t,ownerRows,4)
691691
for_,row:=rangeownerRows {
692-
switchrow.WorkspaceID {
692+
switchrow.ID {
693693
casependingID:
694694
require.Len(t,row.Agents,1)
695695
require.Equal(t,database.ProvisionerJobStatusPending,row.JobStatus)
@@ -705,7 +705,7 @@ func TestGetAuthorizedWorkspacesAndAgents(t *testing.T) {
705705
require.Equal(t,database.ProvisionerJobStatusSucceeded,row.JobStatus)
706706
require.Equal(t,database.WorkspaceTransitionDelete,row.Transition)
707707
default:
708-
t.Fatalf("unexpected workspace ID: %s",row.WorkspaceID)
708+
t.Fatalf("unexpected workspace ID: %s",row.ID)
709709
}
710710
}
711711
}

‎coderd/database/queries.sql.go

Lines changed: 12 additions & 9 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
@@ -690,8 +690,9 @@ UPDATE workspaces SET favorite = false WHERE id = @id;
690690

691691
-- name: GetWorkspacesAndAgents :many
692692
SELECT
693-
workspaces.idas workspace_id,
694-
workspaces.nameas workspace_name,
693+
workspaces.idas id,
694+
workspaces.nameas name,
695+
workspaces.owner_idas owner_id,
695696
job_status,
696697
transition,
697698
(array_agg(ROW(agent_id, agent_name)::agent_id_name_pair) FILTER (WHERE agent_idIS NOT NULL))::agent_id_name_pair[]as agents

‎coderd/database/types.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"database/sql/driver"
55
"encoding/json"
66
"fmt"
7+
"strings"
78
"time"
89

910
"github.com/google/uuid"
@@ -182,13 +183,25 @@ type AgentIDNamePair struct {
182183
}
183184

184185
func (p*AgentIDNamePair)Scan(srcinterface{})error {
185-
switchv:=src.(type) {
186+
varvstring
187+
switcha:=src.(type) {
186188
case []byte:
187-
returnjson.Unmarshal(v,&p)
189+
v=string(a)
188190
casestring:
189-
returnjson.Unmarshal([]byte(v),&p)
191+
v=a
192+
default:
193+
returnxerrors.Errorf("unexpected type %T",src)
190194
}
191-
returnxerrors.Errorf("unexpected type %T",src)
195+
parts:=strings.Split(strings.Trim(v,"()"),",")
196+
iflen(parts)!=2 {
197+
returnxerrors.New("invalid format for AgentIDNamePair")
198+
}
199+
id,err:=uuid.Parse(strings.TrimSpace(parts[0]))
200+
iferr!=nil {
201+
returnerr
202+
}
203+
p.ID,p.Name=id,strings.TrimSpace(parts[1])
204+
returnnil
192205
}
193206

194207
func (pAgentIDNamePair)Value() (driver.Value,error) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp