Skip to content

Commit fef734c

Browse files
committed
feat: leaderboard
1 parent c3d1b2f commit fef734c

File tree

9 files changed

+437
-31
lines changed

9 files changed

+437
-31
lines changed

AVOS/AVOS.xcodeproj/project.pbxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@
302302
D313718026BBDAC200123756 /* LCQueryTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = D313717F26BBDAC200123756 /* LCQueryTestCase.swift */; };
303303
D32AA480263BF2F30044E74E /* Foundation.h in Headers */ = {isa = PBXBuildFile; fileRef = D32AA47F263BF2F30044E74E /* Foundation.h */; settings = {ATTRIBUTES = (Public, ); }; };
304304
D32AA482263BF39C0044E74E /* Realtime.h in Headers */ = {isa = PBXBuildFile; fileRef = D32AA481263BF39C0044E74E /* Realtime.h */; settings = {ATTRIBUTES = (Public, ); }; };
305+
D365E42426C3D29F00148DE8 /* LCLeaderboard.h in Headers */ = {isa = PBXBuildFile; fileRef = D365E42226C3D29F00148DE8 /* LCLeaderboard.h */; settings = {ATTRIBUTES = (Public, ); }; };
306+
D365E42526C3D29F00148DE8 /* LCLeaderboard.m in Sources */ = {isa = PBXBuildFile; fileRef = D365E42326C3D29F00148DE8 /* LCLeaderboard.m */; };
305307
D36A095A25BEA75000A4F312 /* IMMessageTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = D36A095925BEA75000A4F312 /* IMMessageTestCase.swift */; };
306308
D39724C424A5CD3C0099A518 /* RTMBaseTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = D39724C324A5CD3C0099A518 /* RTMBaseTestCase.swift */; };
307309
D39724C624A852400099A518 /* IMClientTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = D39724C524A852400099A518 /* IMClientTestCase.swift */; };
@@ -552,6 +554,8 @@
552554
D34EBDCC211C20FF0092A538 /* LCRouter_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LCRouter_Internal.h; sourceTree = "<group>"; };
553555
D34FD72B2068CFE900B7C11B /* LCLiveQuery_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LCLiveQuery_Internal.h; sourceTree = "<group>"; };
554556
D3596DAC2480EEED002D2D22 /* LCApplication_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LCApplication_Internal.h; sourceTree = "<group>"; };
557+
D365E42226C3D29F00148DE8 /* LCLeaderboard.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LCLeaderboard.h; sourceTree = "<group>"; };
558+
D365E42326C3D29F00148DE8 /* LCLeaderboard.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LCLeaderboard.m; sourceTree = "<group>"; };
555559
D36A095925BEA75000A4F312 /* IMMessageTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IMMessageTestCase.swift; sourceTree = "<group>"; };
556560
D3700B722475244E00678B2B /* LCRTMConnection.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LCRTMConnection.h; sourceTree = "<group>"; };
557561
D3700B732475244E00678B2B /* LCRTMConnection.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LCRTMConnection.m; sourceTree = "<group>"; };
@@ -839,6 +843,7 @@
839843
8C841AA11A5A7A0000C5C6C4 /* Utils */,
840844
83331D421EB9A24D00CADC9C /* Captcha */,
841845
835091FA1EB1BD90000DA884 /* SMS */,
846+
D365E42126C3D23900148DE8 /* Leaderboard */,
842847
);
843848
path = Foundation;
844849
sourceTree = "<group>";
@@ -1279,6 +1284,15 @@
12791284
name = Frameworks;
12801285
sourceTree = "<group>";
12811286
};
1287+
D365E42126C3D23900148DE8 /* Leaderboard */ = {
1288+
isa = PBXGroup;
1289+
children = (
1290+
D365E42226C3D29F00148DE8 /* LCLeaderboard.h */,
1291+
D365E42326C3D29F00148DE8 /* LCLeaderboard.m */,
1292+
);
1293+
path = Leaderboard;
1294+
sourceTree = "<group>";
1295+
};
12821296
D3700B7124750CB300678B2B /* Connection */ = {
12831297
isa = PBXGroup;
12841298
children = (
@@ -1491,6 +1505,7 @@
14911505
D30B6AA524A09E35006ABE09 /* LCDatabaseCommon.h in Headers */,
14921506
D30B6B2124A09F59006ABE09 /* MessagesProtoOrig.pbobjc.h in Headers */,
14931507
D30B6B3A24A09F79006ABE09 /* LCIMMessageCacheStoreSQL.h in Headers */,
1508+
D365E42426C3D29F00148DE8 /* LCLeaderboard.h in Headers */,
14941509
D30B6A6624A09D62006ABE09 /* LCCloudQueryResult.h in Headers */,
14951510
D30B6A8124A09DCA006ABE09 /* LCNetworking.h in Headers */,
14961511
D30B6B3B24A09F79006ABE09 /* LCIMConversationCacheStore.h in Headers */,
@@ -1688,6 +1703,7 @@
16881703
D30B6B5924A09FB6006ABE09 /* LCRTMWebSocket.m in Sources */,
16891704
D30B6A8F24A09DDF006ABE09 /* LCDatabase.m in Sources */,
16901705
D30B6A7724A09DA3006ABE09 /* LCSearchQuery.m in Sources */,
1706+
D365E42526C3D29F00148DE8 /* LCLeaderboard.m in Sources */,
16911707
D30B6AA424A09E35006ABE09 /* LCUtils.m in Sources */,
16921708
D30B6AB924A09E6F006ABE09 /* LCSMS.m in Sources */,
16931709
D30B6AD124A09ED2006ABE09 /* LCIMKeyedConversation.m in Sources */,

AVOS/LeanCloudObjc/Foundation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,6 @@
5959
// SMS & Captcha
6060
#import "LCCaptcha.h"
6161
#import "LCSMS.h"
62+
63+
// Leaderboard
64+
#import "LCLeaderboard.h"
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
//
2+
// LCLeaderboard.h
3+
// LeanCloudObjc
4+
//
5+
// Created by pzheng on 2021/08/11.
6+
// Copyright © 2021 LeanCloud Inc. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
@class LCUser;
12+
13+
NS_ASSUME_NONNULL_BEGIN
14+
15+
@interface LCLeaderboardStatistic : NSObject
16+
17+
@property (nonatomic, readonly, nullable) LCUser *user;
18+
@property (nonatomic, readonly, nullable) NSString *name;
19+
@property (nonatomic, readonly) double value;
20+
@property (nonatomic, readonly) NSInteger version;
21+
22+
@end
23+
24+
@interface LCLeaderboardRanking : NSObject
25+
26+
@property (nonatomic, readonly) NSInteger rank;
27+
@property (nonatomic, readonly) double value;
28+
@property (nonatomic, readonly, nullable) LCUser *user;
29+
@property (nonatomic, readonly, nullable) NSString *statisticName;
30+
@property (nonatomic, readonly) NSArray<LCLeaderboardStatistic *> *includedStatistics;
31+
32+
@end
33+
34+
@interface LCLeaderboardUserQueryOption : NSObject
35+
36+
@property (nonatomic, nullable) NSArray<NSString *> *selectKeys;
37+
@property (nonatomic, nullable) NSArray<NSString *> *includeKeys;
38+
39+
@end
40+
41+
@interface LCLeaderboard : NSObject
42+
43+
@property (nonatomic, readonly) NSString *statisticName;
44+
@property (nonatomic) NSInteger skip;
45+
@property (nonatomic) NSInteger limit;
46+
@property (nonatomic, nullable) NSArray<NSString *> *includeStatistics;
47+
@property (nonatomic, nullable) NSNumber *version;
48+
@property (nonatomic) BOOL returnCount;
49+
50+
+ (instancetype)new NS_UNAVAILABLE;
51+
- (instancetype)init NS_UNAVAILABLE;
52+
53+
- (instancetype)initWithStatisticName:(NSString *)statisticName;
54+
55+
+ (void)updateStatistics:(NSDictionary *)statistics
56+
callback:(void (^)(NSArray<LCLeaderboardStatistic *> * _Nullable statistics, NSError * _Nullable error))callback;
57+
58+
+ (void)getStatisticsWithUserId:(NSString *)userId
59+
statisticNames:(NSArray<NSString *> * _Nullable)statisticNames
60+
option:(LCLeaderboardUserQueryOption * _Nullable)option
61+
callback:(void (^)(NSArray<LCLeaderboardStatistic *> * _Nullable statistics, NSError * _Nullable error))callback;
62+
63+
+ (void)deleteStatistics:(NSArray<NSString *> *)statisticNames
64+
callback:(void (^)(BOOL succeeded, NSError * _Nullable error))callback;
65+
66+
- (void)getStatisticsWithUserIds:(NSArray<NSString *> *)userIds
67+
option:(LCLeaderboardUserQueryOption * _Nullable)option
68+
callback:(void (^)(NSArray<LCLeaderboardStatistic *> * _Nullable statistics, NSError * _Nullable error))callback;
69+
70+
- (void)getResultsWithOption:(LCLeaderboardUserQueryOption * _Nullable)option
71+
callback:(void (^)(NSArray<LCLeaderboardRanking *> * _Nullable rankings, NSInteger count, NSError * _Nullable error))callback;
72+
73+
- (void)getResultsAroundUser:(NSString * _Nullable)userId
74+
option:(LCLeaderboardUserQueryOption * _Nullable)option
75+
callback:(void (^)(NSArray<LCLeaderboardRanking *> * _Nullable rankings, NSInteger count, NSError * _Nullable error))callback;
76+
77+
@end
78+
79+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)