feat: raise the campaign max_new_leads_per_day ceiling to 10000 in the validator, a new CHECK (migration 000422) and the docs, matching the preferences form, and clamp imported values to it

This commit is contained in:
Matthew Meszaros
2026-11-27 16:52:31 +01:00
parent ae8a795602
commit d5ee076e60
8 changed files with 30 additions and 7 deletions
@@ -229,7 +229,7 @@ Create a campaign. Only `name` is required, every other field is optional and ap
| `ramp_ceiling` | integer | no | Ramp ceiling, `1` to `5000` and at least `ramp_start` (default `50`). It never raises a mailbox above its own cap. |
| `warmup_graduation` | boolean | no | Hold mailboxes whose warmup is running or paused to the reply-earned ceiling in this campaign: `5` a day, plus one a day for each lead who replied in the last seven days. Default `true`. `false` leaves each mailbox's daily cap, `daily_limit` and the ramp. The dashboard sets `false` with `ramp_enabled: true` for **On a schedule**, and both `false` for **Full volume**. See [ramp-up](/guides/campaigns/#ramp-up). |
| `esp_match_mode` | string | no | `off`, `prefer`, or `strict`. |
| `max_new_leads_per_day` | integer | no | New-lead throttle, `0` is unlimited. |
| `max_new_leads_per_day` | integer | no | New-lead throttle, `0` is unlimited, up to `10000`. |
| `prioritize_new_leads` | boolean | no | Prefer new leads in each send window. |
| `entry_delay_minutes` | integer | no | Hold a contact's first email this long after they entered the campaign. `0` (the default) sends it as soon as the schedule and mailbox limits allow; the maximum is `129600` (90 days). Follow-up spacing is unaffected: that is each step's `wait_after`. |
| `continuous` | boolean | no | Keep running for new leads: out of leads, the campaign stays `active` and waits instead of finishing. Linking a segment, a form or an automation that enrols leads turns it on, and so does starting a campaign whose every lead has finished. Default `false`. |
+1 -1
View File
@@ -340,7 +340,7 @@ Every option applies as another minimum against the mailbox's own daily cap, the
Changing the option on an active campaign takes effect from its next send. Setting the schedule's numbers again keeps the level it has reached; it never goes back below the start.
**Lead flow** throttles new contacts with **Max new leads per day** (`0` for unlimited, up to `1000`). At the cap, follow-ups to in-flight contacts continue and new leads resume tomorrow. You can prioritize new leads over follow-ups, and choose whether to attempt addresses verification flagged risky.
**Lead flow** throttles new contacts with **Max new leads per day** (`0` for unlimited, up to `10000`). At the cap, follow-ups to in-flight contacts continue and new leads resume tomorrow. You can prioritize new leads over follow-ups, and choose whether to attempt addresses verification flagged risky.
**Keep running for new leads** turns a campaign into an ongoing one: when it runs out of leads it stays **active** and shows **waiting for leads** instead of finishing, then sends the sequence to each lead as they arrive from a linked segment, a form, the API, Zapier, Make, n8n or an automation. Linking a segment, pointing a form at the campaign, or saving an automation that enrols leads in it turns it on, and so does pressing play on a finished campaign whose every lead is done; turn it off in the campaign's preferences to have the campaign finish once every lead is done. A campaign with this on can be started with no leads yet. An end date still ends it.
+1 -1
View File
@@ -38,7 +38,7 @@ func Limits() []LimitGroup {
{"Campaign ramp increment", n(config.CampaignRampIncrementDefault), "emails/day", "Added each day, applied only as a lower bound against the mailbox cap."},
{"Campaign ramp ceiling", n(config.CampaignRampCeilingDefault), "emails/day", "Where the ramp stops lifting."},
{"Sender weight ceiling", n(config.CampaignSenderWeightMax), "weight", "The largest share one mailbox can take in a rotation."},
{"New leads per campaign", n(config.CampaignMaxNewLeadsMax), "contacts", "The most contacts one campaign can pull in per run."},
{"New leads per campaign", n(config.CampaignMaxNewLeadsMax), "contacts/day", "The highest Max new leads per day a campaign accepts."},
},
},
{
+2 -1
View File
@@ -19,6 +19,7 @@ import (
"github.com/warmbly/warmbly/internal/app/campaign"
"github.com/warmbly/warmbly/internal/app/contact"
"github.com/warmbly/warmbly/internal/app/mailboximport"
"github.com/warmbly/warmbly/internal/config"
"github.com/warmbly/warmbly/internal/models"
source "github.com/warmbly/warmbly/internal/pkg/outreachsource"
"github.com/warmbly/warmbly/internal/pkg/tmplvars"
@@ -406,7 +407,7 @@ func (r *run) buildCampaign(c source.Campaign, name string) (*models.CreateCampa
data.DailyLimit = &v
}
if c.MaxNewLeadsPerDay > 0 {
v := c.MaxNewLeadsPerDay
v := min(c.MaxNewLeadsPerDay, config.CampaignMaxNewLeadsMax)
data.MaxNewLeadsPerDay = &v
}
r.schedule(c.Schedule, data, plan)
+1 -1
View File
@@ -47,7 +47,7 @@ const (
CampaignRampStartDefault = 10
CampaignRampIncrementDefault = 5
CampaignRampCeilingDefault = 50
CampaignMaxNewLeadsMax = 1000
CampaignMaxNewLeadsMax = 10000
MaxContactSize = 10240
// MaxEmailBodySize bounds a single stored message body. 200 KB cut real
@@ -0,0 +1,5 @@
-- The old ceiling refuses values above 1000, so clamp them before restoring it.
ALTER TABLE campaigns DROP CONSTRAINT IF EXISTS campaigns_max_new_leads_per_day_range;
UPDATE campaigns SET max_new_leads_per_day = 1000 WHERE max_new_leads_per_day > 1000;
ALTER TABLE campaigns ADD CONSTRAINT campaigns_max_new_leads_per_day_check
CHECK (max_new_leads_per_day >= 0 AND max_new_leads_per_day <= 1000);
@@ -0,0 +1,17 @@
-- Raise the max_new_leads_per_day ceiling from 1000 to 10000 (config.CampaignMaxNewLeadsMax).
-- The 000013 CHECK was unnamed, so drop it by definition rather than by its generated name.
DO $$
DECLARE c record;
BEGIN
FOR c IN
SELECT conname FROM pg_constraint
WHERE conrelid = 'campaigns'::regclass AND contype = 'c'
AND pg_get_constraintdef(oid) LIKE '%max_new_leads_per_day%'
LOOP
EXECUTE format('ALTER TABLE campaigns DROP CONSTRAINT %I', c.conname);
END LOOP;
END $$;
ALTER TABLE campaigns ADD CONSTRAINT campaigns_max_new_leads_per_day_range
CHECK (max_new_leads_per_day >= 0 AND max_new_leads_per_day <= 10000) NOT VALID;
ALTER TABLE campaigns VALIDATE CONSTRAINT campaigns_max_new_leads_per_day_range;
+2 -2
View File
@@ -148,8 +148,8 @@ func CampaignESPMatchMode(s string) *errx.Error {
}
func CampaignMaxNewLeads(v int) *errx.Error {
if v < 0 || v > 1000 {
return errx.New(errx.BadRequest, "max new leads per day must be between 0 and 1000")
if v < 0 || v > config.CampaignMaxNewLeadsMax {
return errx.New(errx.BadRequest, fmt.Sprintf("max new leads per day must be between 0 and %d", config.CampaignMaxNewLeadsMax))
}
return nil
}