Created
November 2, 2019 04:52
-
-
Save rbotzer/de7d3bb86c0d385f2d86406493ca3c26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# assuming it's given once a day, grant the 'top score' award to the | |
# current top score | |
ctx = [ | |
ctxh.cdt_ctx_map_rank(-1), | |
# the attribute map is the second element of the tuple | |
ctxh.cdt_ctx_list_index(1), | |
] | |
ctx2 = ctx + [ctxh.cdt_ctx_map_key("awards")] | |
ops = [ | |
# create the top score award if it doesn't exist | |
mh.map_put("scores", "awards", {"🏆": 0}, { | |
"map_write_flags": aerospike.MAP_WRITE_FLAGS_CREATE_ONLY | |
| aerospike.MAP_WRITE_FLAGS_NO_FAIL | |
}, ctx), | |
mh.map_increment("scores", "🏆", 1, ctx=ctx2), | |
] | |
client.operate(key, ops) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment