Closed Molder72 closed 2 years ago
Hello @Molder72, the first issue you're describing should indeed be fixed in 3.5.0, so I'd kindly ask you to re-test it on that version and let us know if you're still seeing it.
As for updating the metadata, the SET
operator does not support updating an existing record unless the score or subscore are different than existing stored values.
You can achieve updating the metadata only by using a custom query using the nk.sqlExec
runtime function. May I ask what is the use-case that necessitates an update to the record metadata?
yes when i have 5 min re-test point 1 and the other. but I don't think you can set the score to 0, unless you feel it like "undefined" but I retest.
I use the leaderboard metadata because I want all the lists in unity sorted by score, the friends list is actually a leaderboard, the same for the users of a group, or any other list of users, or characters. plus I have add score to the group that at the end is the totat of the users score join to the group.
like in Brawl Stars https://play.google.com/store/apps/details?id=com.supercell.brawlstars&hl=it&gl=US
at the moment in unity i create a list of userIDs from groupUser or friends function, the I read the score, and finaly have to merge users data (displayname, avatar, state in group if the user is in a group, las login date-timethat I have added in the User metadata,....... in future other ) and score.
and merging is complicate, take time, 100 user looping with 100 score, ordered by score
to the other end, if I receive the data to display directly in the leaderboard metadata, I don't have to merge nothing, joust read and show.
and update this metadata in the server is not more heavy, I think, I do it in beforeUpdateAccountFn, afterAuthenticate ( the last login date-time) and some other that now I dont remember.
but yes, the concept is, when I asck from a leaderboard, I want all the data back ready to show.
Setting the score and subscore to 0 with the SET
operator should work as expected.
From my understanding of your use-case, you should create the leaderboard with the ordering you'd like (asc
or desc
), and the incr
(incremental) operator.
You should then submit the scores using leaderboardRecordWrite
by setting the owner ID of the record as the group ID.
I don't see why you'd need to set/update the group users information in the metadata field of the leaderboard record following this approach.
I'll close this issue for now, do leave a comment if you find a bug in the score or subscore submission, but updating the metadata field of a leaderboard record is very specific to your use-case, so we won't be supporting it for now.
If my suggestion above is not helpful to what you're trying to achieve, I'd suggest you create a thread in our forum and we can move the discussion there.
Description
if you set the value of score = 0 it freezes and it is no longer possible to change it (tested in 3.4.0 perhaps in ver 3.5.0 it is solved) example: nk.leaderboardRecordWrite( "Id", ctx.userId, ctx.username, 0, undefined, metadata, nkruntime.OverrideOperator.SET); expectation: no freez
if you set the value of score = subscore value it is not accepted or it is blocked and it is no longer possible to modify it (tested in 3.4.0 perhaps in ver 3.5.0 it is solved) example: nk.leaderboardRecordWrite( "Id", ctx.userId, ctx.username, 123, 123, undefined, nkruntime.OverrideOperator.SET); expectation: no freez
if you set score = 0 return an error (due to constraint it is not possible to set <= 0) but 0 is included in <= (not readly sure, check, if you set subscore != 0 you can set score = 0, maybe) example: nk.leaderboardRecordWrite( "Id", ctx.userId, ctx.username, 0, undefined, undefined, nkruntime.OverrideOperator.SET); expectation: no error
if you set score or subscore as 'undefined' it is reset to 0 (i'm expected that not change the value, because I only want modify the metadata) example: nk.leaderboardRecordWrite( "Id", ctx.userId, ctx.username, undefined, undefined, metadata, nkruntime.OverrideOperator.SET); expectation: before score = 123 before subscore = 0 before metadata = { content json }
after score = 123 after subscore = 0 after metadata = { content json modified }
if you set score and subscore the same value that ready is store in the database, the metadata is nor write in database (as because I can define score 'undefined' i'm expect to only change the metadata ) example: score value in database = 10 subscore value in database = 0 new metadata different from the metadata in database nk.leaderboardRecordWrite( "Id", ctx.userId, ctx.username, 10, 0, metadata, nkruntime.OverrideOperator.SET); expectation: score, subscore, metadata, overwrite even if score and/or subscore value do not change (I know it doesn't make sense to query if the score value doesn't change, but metadata contains everything (displayname, last login date, avatar, ....))
Context
Your Environment