question

ccarlson avatar image
ccarlson asked

Best way to get all users with a specific item

We are having issues finding all players with a specific item. We have had several instances where we want to perform a specific task, whether it be granting them virtual currency or adding a tag, to a user with a specific item. Our current approach has been to get all players through the getPlayersInSegment server SDK and iterating through All Players segment, then looking at each users inventory for the specific item. This operation is working but it takes several hours and will only get longer as we get more players. Is there a better way to get all players with a specific item in their inventory?

Player DatasdksPlayer Inventory
10 |1200

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

1 Answer

·
JayZuo avatar image
JayZuo answered

I'm not sure what your scenario is. But I'd think instead of granting a specific item to the player, you can add a tag at the first. So that you can take Advantage of Segment to get all users. If this can't meet your requirement, then I'm afraid there is no better way. You will have to iterate through All Players and check their inventory. Scheduled Tasks might help you. You can run cloud script on each players in a segment to check if them have a specific item.

2 comments
10 |1200

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

Andy avatar image Andy ♦♦ commented ·

If this is a special scenario and you won't need to do this across multiple items, a tag could definitely work. But if you need a solution that works more generically, you'll want to explore doing it in a data warehouse. We currently support Snowflake and export to your own S3 bucket (which you could then import into your own warehouse). Using a data warehouse, you can run a query on player inventory updates to determine who owns what. You can then push the results of the query into title data periodically or wherever else it might be needed.

Another alternative is to create triggers on inventory events that call webhooks or cloud script and update a database you own with the changes.

1 Like 1 ·
ccarlson avatar image ccarlson Andy ♦♦ commented ·

I think using Snowflake or S3 would be a good solution for us. Thank you very much.

0 Likes 0 ·

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.