mirror of https://github.com/coder/coder.git
function name remove Schedule
This commit is contained in:
parent
a6b5a0bf10
commit
94872aa9a2
|
@ -83,7 +83,7 @@ func (a *StatsAPI) UpdateStats(ctx context.Context, req *agentproto.UpdateStatsR
|
|||
slog.Error(err),
|
||||
)
|
||||
} else {
|
||||
next, allowed := schedule.NextAutostartSchedule(now, workspace.AutostartSchedule.String, templateSchedule)
|
||||
next, allowed := schedule.NextAutostart(now, workspace.AutostartSchedule.String, templateSchedule)
|
||||
if allowed {
|
||||
nextAutostart = next
|
||||
}
|
||||
|
|
|
@ -367,7 +367,7 @@ func isEligibleForAutostart(user database.User, ws database.Workspace, build dat
|
|||
return false
|
||||
}
|
||||
|
||||
nextTransition, allowed := schedule.NextAutostartSchedule(build.CreatedAt, ws.AutostartSchedule.String, templateSchedule)
|
||||
nextTransition, allowed := schedule.NextAutostart(build.CreatedAt, ws.AutostartSchedule.String, templateSchedule)
|
||||
if !allowed {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -6,10 +6,10 @@ import (
|
|||
"github.com/coder/coder/v2/coderd/schedule/cron"
|
||||
)
|
||||
|
||||
// NextAutostartSchedule takes the workspace and template schedule and returns the next autostart schedule
|
||||
// NextAutostart takes the workspace and template schedule and returns the next autostart schedule
|
||||
// after "at". The boolean returned is if the autostart should be allowed to start based on the template
|
||||
// schedule.
|
||||
func NextAutostartSchedule(at time.Time, wsSchedule string, templateSchedule TemplateScheduleOptions) (time.Time, bool) {
|
||||
func NextAutostart(at time.Time, wsSchedule string, templateSchedule TemplateScheduleOptions) (time.Time, bool) {
|
||||
sched, err := cron.Weekly(wsSchedule)
|
||||
if err != nil {
|
||||
return time.Time{}, false
|
||||
|
|
|
@ -47,7 +47,7 @@ type CalculateAutostopParams struct {
|
|||
// WorkspaceAutostart can be the empty string if no workspace autostart
|
||||
// is configured.
|
||||
// If configured, this is expected to be a cron weekly event parsable
|
||||
// by autobuild.NextAutostartSchedule
|
||||
// by autobuild.NextAutostart
|
||||
WorkspaceAutostart string
|
||||
|
||||
Now time.Time
|
||||
|
@ -137,7 +137,7 @@ func CalculateAutostop(ctx context.Context, params CalculateAutostopParams) (Aut
|
|||
// 3. User starts workspace at 9:45pm.
|
||||
// - The initial deadline is calculated to be 9:45am
|
||||
// - This crosses the autostart deadline, so the deadline is extended to 9pm
|
||||
nextAutostart, ok := NextAutostartSchedule(params.Now, params.WorkspaceAutostart, templateSchedule)
|
||||
nextAutostart, ok := NextAutostart(params.Now, params.WorkspaceAutostart, templateSchedule)
|
||||
if ok && autostop.Deadline.After(nextAutostart) {
|
||||
autostop.Deadline = nextAutostart.Add(ttl)
|
||||
}
|
||||
|
|
|
@ -1186,7 +1186,7 @@ func (api *API) workspaceAgentReportStats(rw http.ResponseWriter, r *http.Reques
|
|||
slog.Error(err),
|
||||
)
|
||||
} else {
|
||||
next, allowed := schedule.NextAutostartSchedule(time.Now(), workspace.AutostartSchedule.String, templateSchedule)
|
||||
next, allowed := schedule.NextAutostart(time.Now(), workspace.AutostartSchedule.String, templateSchedule)
|
||||
if allowed {
|
||||
nextAutostart = next
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue