Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds basic syncing with RapidPro, so that our user statistics export can associate outcomes (represented by RapidPro Contact Groups) with users.
The syncing is performed via
python manage.py syncrapidpro
, which will need to be run on a regular basis. An optional--full-resync
flag can be passed, which will take longer but guarantees more accurate syncing.Limitations
This doesn't actually add anything to the user statistics CSV, that will need to be done in a future PR.
Right now this doesn't update Contact Group names if they change, since this would be unusual and the effect of showing a stale group name shouldn't be catastrophic (it's not like we're going to rename the "Tenant wants to file an HP action" group to "Tenant is totally happy with their situation").We now deal with contact group renames in a decent way.The syncing mechanism doesn't currently account for users who might have been in RapidPro before they were tenant app users. For example, if they used the rental history text bot to request their rental history and then signed up for the tenant app, their synced contact group information wouldn't be accurate until they did something in RapidPro to mark their user record as "modified", thereby forcing the initial sync of their info.
We could probably fix this by, say, finding all users who have been created since the last time we synced, and explicitly doing a full sync of their information. Alternatively, we could just do a
--full-resync
on a regular but more infrequent basis, which also takes care of this.The syncing attempts to remember when a user might have been added to a RapidPro Contact Group by storing the first time it saw a user be in a group. This won't necessarily be the date the user actually was associated with the group, but hopefully it will be useful in the future.
To do