question

Michael avatar image
Michael asked

Get Player Count In Segment From Cloud Script

I'm wanting to adjust one of my internal title data parameters using a scheduled task to trigger a cloud script function that references the amount of players in a segment (at this point, a count of the players who have logged in over the past 7 days).

This does seem overall possible, though from what I can see only by using the "Get Players In Segment" call that pulls down far more player data than I need and has some API limitations on it.

All I want is the total count of the players in that segment, not their data. Is there a way to do this with a single call (so I don't have to cycle through all of the player data just to count) or perhaps a better way to accomplish this? I'd like to avoid running my own azure instance to cover this.

CloudScriptscheduled tasksPlayStream
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

If all you want is the count, just call GetPlayersInSegment with MaxBatchSize set to 1. That'll minimize the amount of data returned. And you don't have to use the continuation token at all. In the response you get back, the ProfilesInSegment value is specifically the total number of players in the segment.

Please note that segment evaluation (which is triggered by this call) is very CPU intensive, so you do want to make sure not to call this too frequently. If you're thinking of more than once per hour, we should probably talk through your use case in more detail. And, of course, this should never be triggered from a user action.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Michael avatar image Michael commented ·

That'll work perfectly, I only plan to run this once a week so frequent calls won't be a problem. Thanks

0 Likes 0 ·
Pipeworks Truman avatar image
Pipeworks Truman answered

Can I call this endpoint 12 times in one scheduled task, set to run every hour?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.