@@ -134,7 +134,6 @@ func ListWorkspaceInstancesInRange(ctx context.Context, conn *gorm.DB, from, to
134
134
Where (
135
135
conn .Where ("wsi.stoppingTime >= ?" , TimeToISO8601 (from )).Or ("wsi.stoppingTime = ?" , "" ),
136
136
).
137
- Where ("wsi.startedTime != ?" , "" ).
138
137
Where ("wsi.startedTime < ?" , TimeToISO8601 (to )).
139
138
Where ("wsi.usageAttributionId != ?" , "" ).
140
139
FindInBatches (& instancesInBatch , 1000 , func (_ * gorm.DB , _ int ) error {
@@ -151,17 +150,19 @@ func ListWorkspaceInstancesInRange(ctx context.Context, conn *gorm.DB, from, to
151
150
func queryWorkspaceInstanceForUsage (ctx context.Context , conn * gorm.DB ) * gorm.DB {
152
151
return conn .WithContext (ctx ).
153
152
Table (fmt .Sprintf ("%s as wsi" , (& WorkspaceInstance {}).TableName ())).
154
- Select ("wsi.id as id, " +
155
- "ws.projectId as projectId, " +
156
- "ws.type as workspaceType, " +
157
- "wsi.workspaceClass as workspaceClass, " +
158
- "wsi.usageAttributionId as usageAttributionId, " +
159
- "wsi.startedTime as startedTime, " +
160
- "wsi.stoppingTime as stoppingTime, " +
161
- "ws.ownerId as ownerId, " +
153
+ Select ("wsi.id as id, " +
154
+ "ws.projectId as projectId, " +
155
+ "ws.type as workspaceType, " +
156
+ "wsi.workspaceClass as workspaceClass, " +
157
+ "wsi.usageAttributionId as usageAttributionId, " +
158
+ "wsi.startedTime as startedTime, " +
159
+ "wsi.stoppingTime as stoppingTime, " +
160
+ "ws.ownerId as ownerId, " +
162
161
"ws.id as workspaceId" ,
163
162
).
164
- Joins (fmt .Sprintf ("LEFT JOIN %s AS ws ON wsi.workspaceId = ws.id" , (& Workspace {}).TableName ()))
163
+ Joins (fmt .Sprintf ("LEFT JOIN %s AS ws ON wsi.workspaceId = ws.id" , (& Workspace {}).TableName ())).
164
+ // Instances without a StartedTime never actually started, we're not interested in these.
165
+ Where ("wsi.startedTime != ?" , "" )
165
166
}
166
167
167
168
const (
0 commit comments