@@ -11,6 +11,7 @@ public class LCLeaderboard {
1111 public static final int INVALID_VERSION = -1 ;
1212 public static final String MEMBER_TYPE_USER = "_User" ;
1313 public static final String MEMBER_TYPE_ENTITY = "_Entity" ;
14+ public static final String MEMBER_TYPE_OBJECT = "_Object" ;
1415
1516 static final String ATTR_STATISTIC_NAME = "statisticName" ;
1617 static final String ATTR_MEMBER_TYPE = "memberType" ;
@@ -288,7 +289,26 @@ public static Observable<LCStatisticResult> getMemberStatistics(String memberTyp
288289 }
289290 }
290291
291- static String convertLeaderboardType (String memberType ) {
292+ /**
293+ * query a group of users/objects/entities statistic results.
294+ * @param memberType member type.
295+ * MEMBER_TYPE_USER("_User"): leaderboard target is LCUser
296+ * MEMBER_TYPE_ENTITY("_Entity"): leaderboard target is any entity
297+ * MEMBER_TYPE_ENTITY("_Object"): leaderboard target is LCObject
298+ * @param statisticName statistic names.
299+ * @param targetKeys target ids.
300+ * @return observable instance.
301+ */
302+ public static Observable <LCStatisticResult > queryGroupStatistics (String memberType , String statisticName ,
303+ List <String > targetKeys ) {
304+ if (StringUtil .isEmpty (statisticName )) {
305+ return Observable .error (new IllegalArgumentException ("name is empty" ));
306+ }
307+ String leaderboardType = convertLeaderboardType4Stats (memberType );
308+ return PaasClient .getStorageClient ().getGroupStatistics (leaderboardType , statisticName , targetKeys );
309+ }
310+
311+ static String convertLeaderboardType4Rank (String memberType ) {
292312 String leaderboardType = null ;
293313 if (MEMBER_TYPE_USER .equalsIgnoreCase (memberType )) {
294314 leaderboardType = "user" ;
@@ -300,6 +320,18 @@ static String convertLeaderboardType(String memberType) {
300320 return leaderboardType ;
301321 }
302322
323+ static String convertLeaderboardType4Stats (String memberType ) {
324+ String leaderboardType = null ;
325+ if (MEMBER_TYPE_USER .equalsIgnoreCase (memberType )) {
326+ leaderboardType = "users" ;
327+ } else if (MEMBER_TYPE_ENTITY .equalsIgnoreCase (memberType )) {
328+ leaderboardType = "entities" ;
329+ } else {
330+ leaderboardType = "objects" ;
331+ }
332+ return leaderboardType ;
333+ }
334+
303335 /**
304336 * get leaderboard results.
305337 * @param skip query offset
@@ -328,11 +360,31 @@ public Observable<LCLeaderboardResult> getResults(int skip, int limit, List<Stri
328360 if (StringUtil .isEmpty (this .statisticName )) {
329361 return Observable .error (new IllegalArgumentException ("name is empty" ));
330362 }
331- String leaderboardType = convertLeaderboardType (this .memberType );
363+ String leaderboardType = convertLeaderboardType4Rank (this .memberType );
332364 return PaasClient .getStorageClient ().getLeaderboardResults (leaderboardType , this .statisticName ,
333365 skip , limit , selectMemberKeys , null , includeStatistics , this .version , withCount );
334366 }
335367
368+ /**
369+ * get group user's ranking.
370+ * @param groupUserIds user id list.
371+ * @param skip skip number.
372+ * @param limit max result limitation.
373+ * @param selectMemberKeys select member(user) keys(optional)
374+ * @param includeStatistics include other statistics(optional)
375+ * @return observable instance.
376+ */
377+ public Observable <LCLeaderboardResult > getGroupResults (List <String > groupUserIds ,
378+ int skip , int limit , List <String > selectMemberKeys ,
379+ List <String > includeStatistics ) {
380+ if (StringUtil .isEmpty (this .statisticName )) {
381+ return Observable .error (new IllegalArgumentException ("name is empty" ));
382+ }
383+ String leaderboardType = convertLeaderboardType4Rank (this .memberType );
384+ return PaasClient .getStorageClient ().getLeaderboardGroupResults (leaderboardType , this .statisticName ,
385+ groupUserIds , skip , limit , selectMemberKeys , null , includeStatistics , this .version );
386+ }
387+
336388 /**
337389 * get leaderboard results around target id(user, object or entity).
338390 * @param targetId target objectId
@@ -348,11 +400,40 @@ public Observable<LCLeaderboardResult> getAroundResults(String targetId, int ski
348400 if (StringUtil .isEmpty (this .statisticName )) {
349401 return Observable .error (new IllegalArgumentException ("name is empty" ));
350402 }
351- String leaderboardType = convertLeaderboardType (this .memberType );
403+ String leaderboardType = convertLeaderboardType4Rank (this .memberType );
352404 return PaasClient .getStorageClient ().getLeaderboardAroundResults (leaderboardType , this .statisticName , targetId ,
353405 skip , limit , selectMemberKeys , null , includeStatistics , this .version );
354406 }
355407
408+ /**
409+ * get leaderboard results around target id within specified group.
410+ * @param groupUserIds user id list.
411+ * @param targetId target user id.
412+ * @param limit query limit.
413+ * @param selectMemberKeys select object keys(optional)
414+ * @param includeStatistics include other statistics(optional)
415+ * @return observable instance.
416+ */
417+ public Observable <LCLeaderboardResult > getAroundInGroupResults (List <String > groupUserIds , String targetId , int limit ,
418+ List <String > selectMemberKeys ,
419+ List <String > includeStatistics ) {
420+ if (StringUtil .isEmpty (this .statisticName )) {
421+ return Observable .error (new IllegalArgumentException ("name is empty" ));
422+ }
423+ String leaderboardType = convertLeaderboardType4Rank (this .memberType );
424+ return PaasClient .getStorageClient ().getLeaderboardAroundInGroupResults (leaderboardType , this .statisticName ,
425+ groupUserIds , targetId , limit , selectMemberKeys , null , includeStatistics , this .version );
426+ }
427+
428+ /**
429+ * query multiple users/objects/entities statistic results.
430+ * @param targetKeys target id list.
431+ * @return observable instance.
432+ */
433+ public Observable <LCStatisticResult > queryGroupStatistics (List <String > targetKeys ) {
434+ return queryGroupStatistics (this .memberType , this .statisticName , targetKeys );
435+ }
436+
356437 /**
357438 * create leaderboard with default member type(User).
358439 * @param name name
0 commit comments