mirror of
https://github.com/coder/coder.git
synced 2025-07-06 15:41:45 +00:00
feat: add template activity_bump property (#11734)
Allows template admins to configure the activity bump duration. Defaults to 1h.
This commit is contained in:
@ -841,10 +841,14 @@ func (q *FakeQuerier) ActivityBumpWorkspace(ctx context.Context, arg database.Ac
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if template.ActivityBump == 0 {
|
||||
return nil
|
||||
}
|
||||
activityBump := time.Duration(template.ActivityBump)
|
||||
|
||||
var ttlDur time.Duration
|
||||
if now.Add(time.Hour).After(arg.NextAutostart) && arg.NextAutostart.After(now) {
|
||||
// Extend to TTL
|
||||
if now.Add(activityBump).After(arg.NextAutostart) && arg.NextAutostart.After(now) {
|
||||
// Extend to TTL (NOT activity bump)
|
||||
add := arg.NextAutostart.Sub(now)
|
||||
if workspace.Ttl.Valid && template.AllowUserAutostop {
|
||||
add += time.Duration(workspace.Ttl.Int64)
|
||||
@ -853,7 +857,8 @@ func (q *FakeQuerier) ActivityBumpWorkspace(ctx context.Context, arg database.Ac
|
||||
}
|
||||
ttlDur = add
|
||||
} else {
|
||||
ttlDur = time.Hour
|
||||
// Otherwise, default to regular activity bump duration.
|
||||
ttlDur = activityBump
|
||||
}
|
||||
|
||||
// Only bump if 5% of the deadline has passed.
|
||||
@ -6543,6 +6548,7 @@ func (q *FakeQuerier) UpdateTemplateScheduleByID(_ context.Context, arg database
|
||||
tpl.AllowUserAutostop = arg.AllowUserAutostop
|
||||
tpl.UpdatedAt = dbtime.Now()
|
||||
tpl.DefaultTTL = arg.DefaultTTL
|
||||
tpl.ActivityBump = arg.ActivityBump
|
||||
tpl.UseMaxTtl = arg.UseMaxTtl
|
||||
tpl.MaxTTL = arg.MaxTTL
|
||||
tpl.AutostopRequirementDaysOfWeek = arg.AutostopRequirementDaysOfWeek
|
||||
|
Reference in New Issue
Block a user