Skip to content
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

Merged
merged 23 commits into from
Oct 19, 2022
Merged

feat: support per-campaign autosend limit #1473

merged 23 commits into from
Oct 19, 2022

Conversation

bchrobot
Copy link
Member

@bchrobot bchrobot commented Oct 17, 2022

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):

Screenshot 2022-10-17 at 12 43 17 PM

Save on type

Screenshot 2022-10-17 at 6 04 58 PM

Server error

Documentation Changes

N/A

Checklist:

  • My change requires a change to the documentation.
  • I have included updates for the documentation accordingly.

@bchrobot bchrobot requested review from hiemanshu and ajohn25 October 17, 2022 16:42
@bchrobot bchrobot marked this pull request as ready for review October 17, 2022 22:07
Comment on lines 2004 to 2016
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)
Copy link
Contributor

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

Copy link
Member Author

@bchrobot bchrobot Oct 17, 2022

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Member Author

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in a799bb9

@kohlee
Copy link

kohlee commented Oct 18, 2022

This has been tested in production and we'd like to prioritize its release!

@hiemanshu hiemanshu added this to the 5.0.0 milestone Oct 18, 2022
Copy link
Contributor

@hiemanshu hiemanshu left a 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;
Copy link
Contributor

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.

Copy link
Member Author

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.

src/server/api/schema.js Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autosending contact limit configurable by campaign
5 participants