chore: move template meta last_used_at update to workspacestats (#13415)

This commit is contained in:
Garrett Delfosse
2024-05-31 12:26:19 -04:00
committed by GitHub
parent 19530c6b44
commit de8149fbfd
4 changed files with 33 additions and 19 deletions
+11 -11
View File
@@ -114,38 +114,38 @@ func VerifyTemplateAutostartRequirement(days uint8) error {
}
type TemplateScheduleOptions struct {
UserAutostartEnabled bool `json:"user_autostart_enabled"`
UserAutostopEnabled bool `json:"user_autostop_enabled"`
DefaultTTL time.Duration `json:"default_ttl"`
UserAutostartEnabled bool
UserAutostopEnabled bool
DefaultTTL time.Duration
// ActivityBump dictates the duration to bump the workspace's deadline by if
// Coder detects activity from the user. A value of 0 means no bumping.
ActivityBump time.Duration `json:"activity_bump"`
ActivityBump time.Duration
// AutostopRequirement dictates when the workspace must be restarted. This
// used to be handled by MaxTTL.
AutostopRequirement TemplateAutostopRequirement `json:"autostop_requirement"`
AutostopRequirement TemplateAutostopRequirement
// AutostartRequirement dictates when the workspace can be auto started.
AutostartRequirement TemplateAutostartRequirement `json:"autostart_requirement"`
AutostartRequirement TemplateAutostartRequirement
// FailureTTL dictates the duration after which failed workspaces will be
// stopped automatically.
FailureTTL time.Duration `json:"failure_ttl"`
FailureTTL time.Duration
// TimeTilDormant dictates the duration after which inactive workspaces will
// go dormant.
TimeTilDormant time.Duration `json:"time_til_dormant"`
TimeTilDormant time.Duration
// TimeTilDormantAutoDelete dictates the duration after which dormant workspaces will be
// permanently deleted.
TimeTilDormantAutoDelete time.Duration `json:"time_til_dormant_autodelete"`
TimeTilDormantAutoDelete time.Duration
// UpdateWorkspaceLastUsedAt updates the template's workspaces'
// last_used_at field. This is useful for preventing updates to the
// templates inactivity_ttl immediately triggering a dormant action against
// workspaces whose last_used_at field violates the new template
// inactivity_ttl threshold.
UpdateWorkspaceLastUsedAt bool `json:"update_workspace_last_used_at"`
UpdateWorkspaceLastUsedAt func(ctx context.Context, db database.Store, templateID uuid.UUID, lastUsedAt time.Time) error `json:"update_workspace_last_used_at"`
// UpdateWorkspaceDormantAt updates the template's workspaces'
// dormant_at field. This is useful for preventing updates to the
// templates locked_ttl immediately triggering a delete action against
// workspaces whose dormant_at field violates the new template time_til_dormant_autodelete
// threshold.
UpdateWorkspaceDormantAt bool `json:"update_workspace_dormant_at"`
UpdateWorkspaceDormantAt bool
}
// TemplateScheduleStore provides an interface for retrieving template