From accb67e40715f4d395a260b1e72b07fa3f143472 Mon Sep 17 00:00:00 2001 From: Jamie Doornbos Date: Mon, 27 Jul 2009 21:31:42 +0000 Subject: [PATCH] Allow most recent ratings to be filtered by a specific list of game ids. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@863 c613c5cb-e716-0410-b11b-feb51c14d237 --- .../rating/server/persist/RatingRepository.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/parlor/rating/server/persist/RatingRepository.java b/src/java/com/threerings/parlor/rating/server/persist/RatingRepository.java index 50b2411a..87d99edb 100644 --- a/src/java/com/threerings/parlor/rating/server/persist/RatingRepository.java +++ b/src/java/com/threerings/parlor/rating/server/persist/RatingRepository.java @@ -225,10 +225,22 @@ public class RatingRepository extends DepotRepository * Load the most recently entered rating for each of a collection of players. The search may * be limited to only negative or positive id's since applications may use the sign to indicate * game mode. - * @param sign if < 0, load ratings with negative game id; if > 0, positive; if == 0, all. + * @param gameIdSign if non-zero, limits the search to game ids of matching sign */ public Collection getMostRecentRatings ( Collection playerIds, int gameIdSign) + { + return getMostRecentRatings(playerIds, null, gameIdSign); + } + + /** + * Load the most recently entered rating for each of a collection of players. The search may + * be limited to a specific collection of games. + * @param gameIds if not null, limits the search to the specific game ids + * @param gameIdSign if non-zero, limits the search to game ids of matching sign + */ + public Collection getMostRecentRatings ( + Collection playerIds, Collection gameIds, int gameIdSign) { // TODO: Implement "distinct" in depot. Here's the query I'd like to do: // @@ -241,6 +253,9 @@ public class RatingRepository extends DepotRepository List conditions = Lists.newArrayList(); conditions.add(RatingRecord.PLAYER_ID.in(playerIds)); + if (gameIds != null) { + conditions.add(RatingRecord.GAME_ID.in(gameIds)); + } if (gameIdSign != 0) { conditions.add(gameIdSign < 0 ? RatingRecord.GAME_ID.lessThan(0) : RatingRecord.GAME_ID.greaterThan(0));