GAE datastore query with filter and sort using objectify

后端 未结 3 1986
再見小時候
再見小時候 2021-01-15 04:40

I am trying to query the datastore for the top 100 users in terms of points scored, who have logged on in the past week (the date field).

List use         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-15 05:16

    Thanks tony for taking the time for your great explanations.

    A third more complex but "cleaner" option is also possible

    (yes because you suppose that in the 300 best results, there will be 100 new, so it matematically is incoherent beyond the fact that is uses some bandwith (if in gwt) and resources).

    The third solution is to have a separate table with always at max 100 results sorted by score.

    You can have these 100 rows always in memory.

    Before saving any new entry check

    • if the 100 memory rows are in the date limit and remove the old rows (supposing you have only one date option: eg. best of month)
    • if the current score to save is better that the lowest in 'up to date' entries, add it to the memory cache.

    Now if you have more than one date option: ex: best of day, best of week, best of month Add a column to specify in which category the top 100 element is (and have 300 elements instead of 100, or have a multiple value column and keep 100 entries (with more code complexity))

    Best regards,

提交回复
热议问题