isEligibleForDormantStop returns true if the workspace should be dormant for breaching the inactivity threshold of the template.
(ws database.Workspace, templateSchedule schedule.TemplateScheduleOptions, currentTick time.Time)
| 646 | // isEligibleForDormantStop returns true if the workspace should be dormant |
| 647 | // for breaching the inactivity threshold of the template. |
| 648 | func isEligibleForDormantStop(ws database.Workspace, templateSchedule schedule.TemplateScheduleOptions, currentTick time.Time) bool { |
| 649 | // Only attempt against workspaces not already dormant. |
| 650 | return !ws.DormantAt.Valid && |
| 651 | // The template must specify an time_til_dormant value. |
| 652 | templateSchedule.TimeTilDormant > 0 && |
| 653 | // The workspace must breach the time_til_dormant value. |
| 654 | currentTick.Sub(ws.LastUsedAt) > templateSchedule.TimeTilDormant |
| 655 | } |
| 656 | |
| 657 | func isEligibleForDelete(ws database.Workspace, templateSchedule schedule.TemplateScheduleOptions, lastBuild database.WorkspaceBuild, lastJob database.ProvisionerJob, currentTick time.Time) bool { |
| 658 | eligible := ws.DormantAt.Valid && ws.DeletingAt.Valid && |