It is a common requirement - to be able to loop through all users, or certain categories (i.e. segments) of users, and do some processing on each.
This is especially useful for cases where an app's data structures have changed, and you want to loop through all users to proactively update their data, set new defaults, etc...
And it is especially challenging because apps can have tens of millions of users - and tight loops like this aren't exactly compatible with building large, scalable systems like brainCloud!
The good news is that we've got you covered - the S2S API call RunBatchUserScript().
This script takes 3 parameters:
scriptName- The name of the script to run against each user
scriptData- the parameters for the script being run
segmentIdList- the list of user segments to use to determine which users to run the script against. Pass in an empty array to run it against all users.
An easy way to invoke the RunBatchUserScript() call is via the Design | Cloud Code | S2S Explorer page. Note - you will need to at least define a server via the Design | Cloud Code | S2S Config page first.
Once invoked, this call schedules a background task that will invoke the specified script on the specified population of users. Completing the batch can take anywhere from several minutes to an hour or more depending upon the number of users involved.
You can check the logs in Monitoring | Global Monitoring | Recent Errors to confirm that the job has completed and see how many users were processed. [Hint: Be sure to turn on Info messages and hit the [Refresh] button].
Note that normal brainCloud billing fees apply: You get charged 1 API count for the RunBatchUserScript() call itself, 1 API count for each user that
scriptName is run against, with the normal assortment of free and 1/2 price API calls for calls made within the scripts themselves.
We hope this helps! If you have any further questions, feel free to reach out!
Your feedback is important to us. Please rate this response below. Thanks!