mirror of
https://github.com/warmbly/warmbly.git
synced 2026-11-25 00:07:07 +00:00
feat: report workspace risk on a projected full-day hold, cap the iOS ramp start at the current ceiling, and pin the restricted ramp projection test to its expected three sends
This commit is contained in:
@@ -139,6 +139,14 @@ type projectedSender struct {
|
||||
sentAll int
|
||||
}
|
||||
|
||||
// riskCut is what workspace risk takes from a cap, as stagedCap rounds it.
|
||||
func (p *projectedSender) riskCut(c int) int {
|
||||
if m := p.risk.CapMultiplier(); m < 1 {
|
||||
return max(0, c-max(1, int(float64(c)*m+0.5)))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// senderDay is one mailbox's day with the clamps that shaped it.
|
||||
type senderDay struct {
|
||||
sends, warmup int
|
||||
@@ -206,7 +214,8 @@ func projectSenderDay(p *projectedSender, spans []span, midnight, rampStart time
|
||||
c := p.cap
|
||||
if p.held {
|
||||
if p.heldTill == nil || !p.heldTill.Before(spans[len(spans)-1].to) {
|
||||
d.held = c
|
||||
d.risk = p.riskCut(c)
|
||||
d.held = c - d.risk
|
||||
return d
|
||||
}
|
||||
spans = clipSpans(spans, *p.heldTill)
|
||||
@@ -229,12 +238,8 @@ func projectSenderDay(p *projectedSender, spans []span, midnight, rampStart time
|
||||
c = g
|
||||
}
|
||||
}
|
||||
if m := p.risk.CapMultiplier(); m < 1 {
|
||||
if r := max(1, int(float64(c)*m+0.5)); r < c {
|
||||
d.risk = c - r
|
||||
c = r
|
||||
}
|
||||
}
|
||||
d.risk = p.riskCut(c)
|
||||
c -= d.risk
|
||||
|
||||
// The mailbox's own clock: a behaviour profile's workday, or the 8am-8pm
|
||||
// band in its own timezone when that differs from the campaign's.
|
||||
|
||||
@@ -50,10 +50,15 @@ func TestProjectSenderDayAppliesTheCampaignRamp(t *testing.T) {
|
||||
}
|
||||
// Workspace risk cuts what the ramp left, as stagedCap does.
|
||||
p.risk = models.OrgRiskRestricted
|
||||
want := max(1, int(10*p.risk.CapMultiplier()+0.5))
|
||||
want := 3
|
||||
if d := projectSenderDay(p, spans, mid, day, false, 10); d.sends != want || d.ramp != 40 || d.risk != 10-want {
|
||||
t.Fatalf("restricted: got %+v, want %d sends after the ramp", d, want)
|
||||
}
|
||||
// A held day still reports what risk would have taken.
|
||||
p.cap, p.held = 40, true
|
||||
if d := projectSenderDay(p, spans, mid, day, false, -1); d.sends != 0 || d.risk != 30 || d.held != 10 {
|
||||
t.Fatalf("held and restricted: got %+v, want 30 to risk and 10 held", d)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNextRampLevelStartsAtRampStart(t *testing.T) {
|
||||
|
||||
@@ -181,8 +181,8 @@ struct CampaignSettingsPage: View {
|
||||
)
|
||||
if campaign.rampEnabled == true {
|
||||
stepperRow(
|
||||
"Start", subtitle: "emails/day on day one", icon: "1.circle.fill", tone: .orange,
|
||||
value: campaign.rampStart ?? 10, range: 1...5000,
|
||||
"Start", subtitle: "emails/day on day one, up to the ceiling", icon: "1.circle.fill", tone: .orange,
|
||||
value: campaign.rampStart ?? 10, range: 1...min(max(campaign.rampCeiling ?? 50, 1), 5000),
|
||||
body: { CampaignUpdateBody(rampStart: $0) }, mutate: { $0.rampStart = $1 }
|
||||
)
|
||||
stepperRow(
|
||||
|
||||
Reference in New Issue
Block a user