Skip to content

What’s the best way to handle players with a large number of games? #274

@refear99

Description

@refear99

In my use case, both new and existing players may update their trophy data — either for the first time or multiple times.

I first use $user->trophyTitles() to populate new titles, groups, and trophies into my database.
Then I asynchronously call $client->trophies() to fetch their multi-language data — mainly the default en-US and my local language.


How can this be handled efficiently?

For example, the user ikemenzi has over 18,000 trophy groups and 200,000 trophies.
Since each page returns 100 items, it takes around 180 API calls to fully loop through $user->trophyTitles().

Currently, when a user updates their trophy data, I loop through $user->trophyTitles().
If I find that the lastUpdatedDateTime of a game matches the one stored in my database, I stop the loop.

Because newly updated games appear first in the list, if game N has the same lastUpdatedDateTime as in my database, I assume that games after N haven’t been updated either.
(Am I understanding that correctly?)

Here’s a table showing the comparison logic:

Game Name PSN lastUpdatedDateTime DB Timestamp Needs Update Comparison Result
Game A 2025-07-30T12:00:00Z 2025-07-29T12:00:00Z ✅ Yes PSN timestamp is newer, update required
Game B 2025-07-28T10:30:00Z 2025-07-28T10:00:00Z ✅ Yes PSN timestamp is slightly newer, update required
Game C 2025-07-25T08:15:00Z 2025-07-25T08:15:00Z ❌ No Same timestamp as DB, assume no further updates
Game D 2025-07-22T14:00:00Z 2025-07-22T14:00:00Z ❌ No Same timestamp, skip

I break the loop at Game C, since its timestamp hasn’t changed. That means Game C and everything after (D, E, etc.) are assumed to be unchanged and are skipped.

Does anyone have better or more efficient strategies for handling this kind of large-scale trophy syncing?

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions