A possible extension to this service would be to store leaderboards by country and by quest.
These leaderboards should not be shown directly in the app but shown for example like this:
in the profile screen where the total star count is shown, a string like "#75 worldwide, #2 in Denmark" could be shown
in the quest type details dialog where the star count for that quest type is shown, the same could be shown for that quest type
So, you can see how you are doing yourself, but there is no direct comparison to other users.
Taken into account for these leaderboards would only the users currently in the database.
Depending on the runtime of the SQL queries to ascertain the rank of a user worldwide, in his country, and the same for each quest type, it will most probably be necessary to add additional tables in which to store the leaderboards and update these tables in a scheduled task.
Implementation-wise, there should be DAO(s) for these table(s), a script that updates these tables and probably the whole JSON-generation for the API should move into an own class instead of being in get_statistics.php.
A possible extension to this service would be to store leaderboards by country and by quest.
These leaderboards should not be shown directly in the app but shown for example like this:
So, you can see how you are doing yourself, but there is no direct comparison to other users.
Taken into account for these leaderboards would only the users currently in the database. Depending on the runtime of the SQL queries to ascertain the rank of a user worldwide, in his country, and the same for each quest type, it will most probably be necessary to add additional tables in which to store the leaderboards and update these tables in a scheduled task.
Implementation-wise, there should be DAO(s) for these table(s), a script that updates these tables and probably the whole JSON-generation for the API should move into an own class instead of being in get_statistics.php.