Sorting on a combination of multiple streams

MetaGame generates a leaderboard based on the allocation of a token to the participants.

Currently, our profiles (in staging) are generated directly from the Ceramic node, but the leaderboard requires us to cache everything in Hasura (a GraphQL frontend to Postgresql) since, until very recently, there was no ability to sort in ComposeDB.

What I would like to do is create a process that maintains a stream with users’ XP values and have that stream associated with the users’ profiles in such a way that I can pull the sorted leaderboard list (paginated) from our ComposeDB instance.

The XP stream would be owned by a DID:key running automated process while the profile information would be controlled by a traditional DID:PKH from the user.

@golda, you thought you might have a lead on an answer to this.

An additional wrinkle is the goal for the system is to deliver a leaderboard for any organization that has token-rewarded contributions, so there will be multiple computer-written streams for different orgs, possibly more than one for a given user.

So it sounds like you want the ability to do a query on Model A and sort it, not on a field in Model A, but on a field in Model B where Model A has a relation so every ModelA document has a link to a ModelB document, and you want to use a field in the linked document as the sort key. Am I understanding this right?

This is not currently possible with the built-in GraphQL query endpoints. We are planning to enable more complex custom queries in the future though, and this type of more advanced sorting logic would likely make sense to consider as part of that work. CC @paul and @jpham to track the feature request.