-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support per-campaign autosend limit #1473
Conversation
src/server/api/schema.js
Outdated
autosend_limit_max_contact_id = (case | ||
when ?::int is not null then ( | ||
select max(id) | ||
from ( | ||
select id | ||
from campaign_contact | ||
where campaign_id = ?::int | ||
order by id asc | ||
limit ?::int | ||
) campaign_contact_ids | ||
) | ||
else null | ||
end) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the reason we handle the case where limit is null so that this query can double for setting autosend_limit/max_contact_id to null?
nit: I think it'd be easier to read as 2 separate queries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that was the reason. I've split it into two queries in 2aac286.
group by 1 | ||
and organization_id = $1 | ||
and campaign_summary.campaign_id = campaign.id | ||
and new_autosend_status is not null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and new_autosend_status is not null | |
and new_autosend_status is not null | |
and id = ANY($2::integer[]) |
We only want to be able to mark campaigns as complete that we just queued, right? That's preserving previous behavior
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The limit to $2
campaign IDs passes through from campaign_summary_raw
but I'm happy to duplicate it in the update
as a safety
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in a799bb9
This has been tested in production and we'd like to prioritize its release! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! A few nitpicks / suggestions.
return knex.schema | ||
.raw( | ||
` | ||
drop view campaign cascade; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment: I hate how much work this requires. abysmal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep :(
I would back a proposal for Rewired to sponsor development of an alter view drop column
. There's been discussion about this since 2008.
Description
This allows autosend admins to specify a contact count limit for autosending. When set, the first n messages will go out and then the campaign will pause.
Motivation and Context
Closes #1318.
How Has This Been Tested?
See tests added in PR.
Screenshots (if appropriate):
Save on type
Server error
Documentation Changes
N/A
Checklist: