-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[usage] Filter out not started workspace instances #12696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,6 +134,7 @@ func ListWorkspaceInstancesInRange(ctx context.Context, conn *gorm.DB, from, to | |
Where( | ||
conn.Where("wsi.stoppingTime >= ?", TimeToISO8601(from)).Or("wsi.stoppingTime = ?", ""), | ||
). | ||
Where("wsi.startedTime != ?", ""). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where we filter out any without a started time |
||
Where("wsi.startedTime < ?", TimeToISO8601(to)). | ||
Where("wsi.usageAttributionId != ?", ""). | ||
FindInBatches(&instancesInBatch, 1000, func(_ *gorm.DB, _ int) error { | ||
|
@@ -155,10 +156,8 @@ func queryWorkspaceInstanceForUsage(ctx context.Context, conn *gorm.DB) *gorm.DB | |
"ws.type as workspaceType, " + | ||
"wsi.workspaceClass as workspaceClass, " + | ||
"wsi.usageAttributionId as usageAttributionId, " + | ||
"wsi.creationTime as creationTime, " + | ||
"wsi.startedTime as startedTime, " + | ||
"wsi.stoppingTime as stoppingTime, " + | ||
"wsi.stoppedTime as stoppedTime, " + | ||
"ws.ownerId as ownerId, " + | ||
"ws.id as workspaceId", | ||
). | ||
|
@@ -224,10 +223,8 @@ type WorkspaceInstanceForUsage struct { | |
Type WorkspaceType `gorm:"column:workspaceType;type:char;size:16;default:regular;" json:"workspaceType"` | ||
UsageAttributionID AttributionID `gorm:"column:usageAttributionId;type:varchar;size:60;" json:"usageAttributionId"` | ||
|
||
CreationTime VarcharTime `gorm:"column:creationTime;type:varchar;size:255;" json:"creationTime"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removes these fields as they are just confusing. They did not get removed originally when we switched to |
||
StartedTime VarcharTime `gorm:"column:startedTime;type:varchar;size:255;" json:"startedTime"` | ||
StoppingTime VarcharTime `gorm:"column:stoppingTime;type:varchar;size:255;" json:"stoppingTime"` | ||
StoppedTime VarcharTime `gorm:"column:stoppedTime;type:varchar;size:255;" json:"stoppedTime"` | ||
} | ||
|
||
// WorkspaceRuntimeSeconds computes how long this WorkspaceInstance has been running. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯