MCPcopy Index your code
hub / github.com/coder/coder / scheduleListRowFromWorkspace

Function scheduleListRowFromWorkspace

cli/schedule.go:360–386  ·  view source on GitHub ↗
(now time.Time, workspace codersdk.Workspace)

Source from the content-addressed store, hash-verified

358}
359
360func scheduleListRowFromWorkspace(now time.Time, workspace codersdk.Workspace) scheduleListRow {
361 autostartDisplay := ""
362 nextStartDisplay := ""
363 if !ptr.NilOrEmpty(workspace.AutostartSchedule) {
364 if sched, err := cron.Weekly(*workspace.AutostartSchedule); err == nil {
365 autostartDisplay = sched.Humanize()
366 nextStartDisplay = timeDisplay(sched.Next(now))
367 }
368 }
369
370 autostopDisplay := ""
371 nextStopDisplay := ""
372 if !ptr.NilOrZero(workspace.TTLMillis) {
373 dur := time.Duration(*workspace.TTLMillis) * time.Millisecond
374 autostopDisplay = durationDisplay(dur)
375 if !workspace.LatestBuild.Deadline.IsZero() && workspace.LatestBuild.Transition == codersdk.WorkspaceTransitionStart {
376 nextStopDisplay = timeDisplay(workspace.LatestBuild.Deadline.Time)
377 }
378 }
379 return scheduleListRow{
380 WorkspaceName: workspace.OwnerName + "/" + workspace.Name,
381 StartsAt: autostartDisplay,
382 StartsNext: nextStartDisplay,
383 StopsAfter: autostopDisplay,
384 StopsNext: nextStopDisplay,
385 }
386}

Callers 1

Calls 9

NilOrEmptyFunction · 0.92
WeeklyFunction · 0.92
NilOrZeroFunction · 0.92
timeDisplayFunction · 0.85
durationDisplayFunction · 0.85
DurationMethod · 0.80
NextMethod · 0.65
HumanizeMethod · 0.45
IsZeroMethod · 0.45

Tested by

no test coverage detected