Spoke
Spoke copied to clipboard
Bug: Ghost Replies / Contacts
Describe the bug When 1 contact is in 2 campaigns and is marked as opt out in 1 of the campaigns the other campaign does not properly exclude that contact from the total count of contacts. This means the "Initials" box can never be 100% which is very confusing.
Also if a reply link is set to give out 10 replies but 5 people are opted out it will only give 5 replies to a person.
To Reproduce Steps to reproduce the behavior:
- Set up 2 campaigns with the same contact in both and a few other random contacts.
- In the first campaign start the convo and opt them out.
- Then get initials from the next campaign and send them all
- Observe how the campaign never hit 100%
Expected behavior Total Contacts should always represent the number of people who are textable. An op-out from the first campaign should drop the total count from other campaigns.
if a reply link is supposed to give out 10 replies it should find 10 people who can be texted.
After some pairing with @Arique1104 we found the possible source.
The issue is that optouts are not being excluded from the counts on the TexterTodos page.
The TexterTodo interface is in this file with counts called from the GraphQl assignment root query here: https://github.com/MoveOnOrg/Spoke/blob/main/src/containers/TexterTodo.jsx#L146-L162 That calls this query: https://github.com/MoveOnOrg/Spoke/blob/main/src/server/api/schema.js#L1389-L1426 which after loading the assignment calls contactsCount (w/ diff parameters) here: https://github.com/MoveOnOrg/Spoke/blob/main/src/server/api/assignment.js#L244
contactsCount has some additional complexity because it is ALSO called from the TexterTodoList.jsx file through user/todos clientside: https://github.com/MoveOnOrg/Spoke/blob/main/src/containers/TexterTodoList.jsx#L149-L184 serverside: https://github.com/MoveOnOrg/Spoke/blob/main/src/server/api/user.js#L253
The todos call has a bunch of extra complexity which loads contacts counts and does a group by and creates counts to 'service' the assignment.contactsCount calls. The todos complexity is here:
https://github.com/MoveOnOrg/Spoke/blob/main/src/server/api/user.js#L298-L365
Significantly, in the path for the TexterTodosList user/todos query we DO filter for is_opted_out: https://github.com/MoveOnOrg/Spoke/blob/main/src/server/api/user.js#L304-L305
but we don't in the TexterTodo.jsx page for the counts.
One approach would be to make sure the count queries in contactsCount are running/doing the right things when the query is being run. -- maybe the MAIN bug is just in contactsCount: https://github.com/MoveOnOrg/Spoke/blob/main/src/server/api/assignment.js#L244 either here: https://github.com/MoveOnOrg/Spoke/blob/main/src/server/api/assignment.js#L258-L268 or somewhere else in the contactsCount method and then to make sure that the TexterTodos query filters out isOptedOut: false
amazing research!
@n0land0 @schuyler1d
We completed this:
https://github.com/MoveOnOrg/Spoke/blob/main/src/server/api/assignment.js#L258-L268 or somewhere else in the contactsCount method and then to make sure that the TexterTodos query filters out isOptedOut: false
We are hoping to create a new experiment to see if there is an additional bug in the server api call for contactCounts
- Creating Campaign
- With same contacts
- Opt out a few
- Check the database with the following sql queries and ensure these numbers are reflected in the TexterTodo countdown
@schuyler1d @Arique1104
Work done & PR'd this morning:
-
src/containers/TexterTodo.jsx
: AddisOptedOut
field toallContactsCount
and set value tofalse
- Test to ensure opt-out status persists across campaigns when creating a new campaign
- Test to ensure that, if same contacts are loaded to two new campaigns simultaneously, the second campaign's total contacts update when a shared contact opts out of the first campaign