Skip to content

Commit 0692172

Browse files
committed
fix: wiring
1 parent 484b9b8 commit 0692172

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

api/v1/server/handlers/workers/get.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ func (t *WorkerService) workerGetV1(ctx echo.Context, tenant *sqlcv1.Tenant, req
2727
return nil, err
2828
}
2929

30-
workerIdToActions, err := t.config.V1.Workers().GetWorkerActionsByWorkerId(
30+
workerIdToActions, err := t.config.V1.Workers().GetWorkerActionsForWorkers(
3131
reqCtx,
3232
worker.Worker.TenantId,
33-
[]uuid.UUID{worker.Worker.ID},
33+
[]sqlcv1.Worker{worker.Worker},
3434
)
3535

3636
if err != nil {

api/v1/server/handlers/workers/list.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,21 +99,27 @@ func (t *WorkerService) workerListV1(ctx echo.Context, tenant *sqlcv1.Tenant, re
9999
telemetry.AttributeKV{Key: "tenant.id", Value: tenant.ID},
100100
)
101101

102-
workers, err := t.config.V1.Workers().ListWorkers(listCtx, tenantId, opts)
102+
workerRows, err := t.config.V1.Workers().ListWorkers(listCtx, tenantId, opts)
103103

104104
if err != nil {
105105
listSpan.RecordError(err)
106106
return nil, err
107107
}
108108

109+
workers := make([]sqlcv1.Worker, len(workerRows))
110+
111+
for i, workerRow := range workerRows {
112+
workers[i] = workerRow.Worker
113+
}
114+
109115
telemetry.WithAttributes(listSpan,
110116
telemetry.AttributeKV{Key: "workers.count", Value: len(workers)},
111117
)
112118

113119
workerIdSet := make(map[uuid.UUID]struct{})
114120

115121
for _, worker := range workers {
116-
workerIdSet[worker.Worker.ID] = struct{}{}
122+
workerIdSet[worker.ID] = struct{}{}
117123
}
118124

119125
workerIds := make([]uuid.UUID, 0, len(workerIdSet))
@@ -128,10 +134,10 @@ func (t *WorkerService) workerListV1(ctx echo.Context, tenant *sqlcv1.Tenant, re
128134
telemetry.AttributeKV{Key: "workers.unique_ids.count", Value: len(workerIds)},
129135
)
130136

131-
workerIdToActionIds, err := t.config.V1.Workers().GetWorkerActionsByWorkerId(
137+
workerIdToActionIds, err := t.config.V1.Workers().GetWorkerActionsForWorkers(
132138
listCtx,
133139
tenant.ID,
134-
workerIds,
140+
workers,
135141
)
136142

137143
if err != nil {
@@ -160,11 +166,11 @@ func (t *WorkerService) workerListV1(ctx echo.Context, tenant *sqlcv1.Tenant, re
160166

161167
for i, worker := range workers {
162168
workerCp := worker
163-
actions := workerIdToActionIds[workerCp.Worker.ID.String()]
164-
slotConfig := workerSlotConfig[workerCp.Worker.ID]
165-
labels := workerIdToLabels[workerCp.Worker.ID]
169+
actions := workerIdToActionIds[workerCp.ID.String()]
170+
slotConfig := workerSlotConfig[workerCp.ID]
171+
labels := workerIdToLabels[workerCp.ID]
166172

167-
rows[i] = *transformersv1.ToWorkerSqlc(&workerCp.Worker, slotConfig, actions, nil, labels)
173+
rows[i] = *transformersv1.ToWorkerSqlc(&workerCp, slotConfig, actions, nil, labels)
168174
}
169175

170176
return gen.WorkerList200JSONResponse(

0 commit comments

Comments
 (0)