How to keep an ordered list on the App Engine DataStore, in a way each entity knows its position on the list? -
i have ranking of people, based on points earn. need tell each participant position on game example, john (1) - 170 points, mary (2) - 160 points, sarah (3) - 110 points
so john's first one, mary's seconds , sarah's third. if mary wins 20 more points, she'll first , john second.
i'm trying avoid having run task on cron list , recalculate everybody's position.
my first try maintain separate set of entities (personrank) wouldn't run transaction problems, rank have same key name, db.get() key. entity have person's calculated rank, when person receives points, i'd have check if next person on line has fewer points me, , exchange places me that's true. problem sarah, on example, may have won 100 points, , number one. on previous algorithm, i'd have "walk" among lot of entities, means lot of datastore gets , puts (updating each involved entity new position).
my next guess maybe kind of linked list referenceproperties, maybe using key names denote position.
any clues how implement ?
much more complex though, guys @ google implemented solution - http://googleappengine.blogspot.com/2009/01/google-code-jams-ranking-library.html
Comments
Post a Comment