doc: leaderboard
parent
a4be2b8bb5
commit
52044b9071
|
@ -26,35 +26,68 @@ namespace LeanCloud.Storage {
|
||||||
Month
|
Month
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// LCLeaderboard represents LeanCloud leaderboard and contains static functions
|
||||||
|
/// that handle the statistic.
|
||||||
|
/// </summary>
|
||||||
public class LCLeaderboard {
|
public class LCLeaderboard {
|
||||||
|
/// <summary>
|
||||||
|
/// The name of statistic.
|
||||||
|
/// </summary>
|
||||||
public string StatisticName {
|
public string StatisticName {
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The order of this leaderboard.
|
||||||
|
/// </summary>
|
||||||
public LCLeaderboardOrder Order {
|
public LCLeaderboardOrder Order {
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The update strategy of this leaderboard.
|
||||||
|
/// </summary>
|
||||||
public LCLeaderboardUpdateStrategy UpdateStrategy {
|
public LCLeaderboardUpdateStrategy UpdateStrategy {
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The interval of the version that the leaderboard resets.
|
||||||
|
/// </summary>
|
||||||
public LCLeaderboardVersionChangeInterval VersionChangeInterval {
|
public LCLeaderboardVersionChangeInterval VersionChangeInterval {
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The version of this leaderboard.
|
||||||
|
/// </summary>
|
||||||
public int Version {
|
public int Version {
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The next time that the leaderboard resets.
|
||||||
|
/// </summary>
|
||||||
public DateTime NextResetAt {
|
public DateTime NextResetAt {
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The time that the leaderboard created.
|
||||||
|
/// </summary>
|
||||||
public DateTime CreatedAt {
|
public DateTime CreatedAt {
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a LCLeaderboard with a statistic name.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="statisticName"></param>
|
||||||
|
/// <param name="order"></param>
|
||||||
|
/// <param name="updateStrategy"></param>
|
||||||
|
/// <param name="versionChangeInterval"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static async Task<LCLeaderboard> CreateLeaderboard(string statisticName,
|
public static async Task<LCLeaderboard> CreateLeaderboard(string statisticName,
|
||||||
LCLeaderboardOrder order = LCLeaderboardOrder.Descending,
|
LCLeaderboardOrder order = LCLeaderboardOrder.Descending,
|
||||||
LCLeaderboardUpdateStrategy updateStrategy = LCLeaderboardUpdateStrategy.Better,
|
LCLeaderboardUpdateStrategy updateStrategy = LCLeaderboardUpdateStrategy.Better,
|
||||||
|
@ -90,12 +123,23 @@ namespace LeanCloud.Storage {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the LCLeaderboard with the given name.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="statisticName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Task<LCLeaderboard> GetLeaderboard(string statisticName) {
|
public static Task<LCLeaderboard> GetLeaderboard(string statisticName) {
|
||||||
LCLeaderboard leaderboard = CreateWithoutData(statisticName);
|
LCLeaderboard leaderboard = CreateWithoutData(statisticName);
|
||||||
return leaderboard.Fetch();
|
return leaderboard.Fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the statistic of the user.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user"></param>
|
||||||
|
/// <param name="statistics"></param>
|
||||||
|
/// <param name="overwrite"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static async Task<ReadOnlyCollection<LCStatistic>> UpdateStatistics(LCUser user,
|
public static async Task<ReadOnlyCollection<LCStatistic>> UpdateStatistics(LCUser user,
|
||||||
Dictionary<string, double> statistics,
|
Dictionary<string, double> statistics,
|
||||||
bool overwrite = false) {
|
bool overwrite = false) {
|
||||||
|
@ -127,7 +171,12 @@ namespace LeanCloud.Storage {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the statistics of the user.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user"></param>
|
||||||
|
/// <param name="statisticNames"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static async Task<ReadOnlyCollection<LCStatistic>> GetStatistics(LCUser user,
|
public static async Task<ReadOnlyCollection<LCStatistic>> GetStatistics(LCUser user,
|
||||||
IEnumerable<string> statisticNames = null) {
|
IEnumerable<string> statisticNames = null) {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
@ -151,7 +200,12 @@ namespace LeanCloud.Storage {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes the statistics of the user with the given name.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user"></param>
|
||||||
|
/// <param name="statisticNames"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static async Task DeleteStatistics(LCUser user,
|
public static async Task DeleteStatistics(LCUser user,
|
||||||
IEnumerable<string> statisticNames) {
|
IEnumerable<string> statisticNames) {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
@ -195,7 +249,15 @@ namespace LeanCloud.Storage {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the rankings.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="version"></param>
|
||||||
|
/// <param name="skip"></param>
|
||||||
|
/// <param name="limit"></param>
|
||||||
|
/// <param name="selectUserKeys"></param>
|
||||||
|
/// <param name="includeStatistics"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public Task<ReadOnlyCollection<LCRanking>> GetResults(int version = -1,
|
public Task<ReadOnlyCollection<LCRanking>> GetResults(int version = -1,
|
||||||
int skip = 0,
|
int skip = 0,
|
||||||
int limit = 10,
|
int limit = 10,
|
||||||
|
@ -204,7 +266,15 @@ namespace LeanCloud.Storage {
|
||||||
return GetResults(null, version, skip, limit, selectUserKeys, includeStatistics);
|
return GetResults(null, version, skip, limit, selectUserKeys, includeStatistics);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the rankings that around the currently logged in user.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="version"></param>
|
||||||
|
/// <param name="skip"></param>
|
||||||
|
/// <param name="limit"></param>
|
||||||
|
/// <param name="selectUserKeys"></param>
|
||||||
|
/// <param name="includeStatistics"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public async Task<ReadOnlyCollection<LCRanking>> GetResultsAroundUser(int version = -1,
|
public async Task<ReadOnlyCollection<LCRanking>> GetResultsAroundUser(int version = -1,
|
||||||
int skip = 0,
|
int skip = 0,
|
||||||
int limit = 10,
|
int limit = 10,
|
||||||
|
@ -214,6 +284,16 @@ namespace LeanCloud.Storage {
|
||||||
return await GetResults(user, version, skip, limit, selectUserKeys, includeStatistics);
|
return await GetResults(user, version, skip, limit, selectUserKeys, includeStatistics);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the rankings of the user.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="user"></param>
|
||||||
|
/// <param name="version"></param>
|
||||||
|
/// <param name="skip"></param>
|
||||||
|
/// <param name="limit"></param>
|
||||||
|
/// <param name="selectUserKeys"></param>
|
||||||
|
/// <param name="includeStatistics"></param>
|
||||||
|
/// <returns></returns>
|
||||||
private async Task<ReadOnlyCollection<LCRanking>> GetResults(LCUser user,
|
private async Task<ReadOnlyCollection<LCRanking>> GetResults(LCUser user,
|
||||||
int version,
|
int version,
|
||||||
int skip,
|
int skip,
|
||||||
|
@ -249,7 +329,11 @@ namespace LeanCloud.Storage {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the update strategy of this LCLeaderboard.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="updateStrategy"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public async Task<LCLeaderboard> UpdateUpdateStrategy(LCLeaderboardUpdateStrategy updateStrategy) {
|
public async Task<LCLeaderboard> UpdateUpdateStrategy(LCLeaderboardUpdateStrategy updateStrategy) {
|
||||||
Dictionary<string, object> data = new Dictionary<string, object> {
|
Dictionary<string, object> data = new Dictionary<string, object> {
|
||||||
{ "updateStrategy", updateStrategy.ToString().ToLower() }
|
{ "updateStrategy", updateStrategy.ToString().ToLower() }
|
||||||
|
@ -264,7 +348,11 @@ namespace LeanCloud.Storage {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the interval of the version that this LCLeaderboard changes.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="versionChangeInterval"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public async Task<LCLeaderboard> UpdateVersionChangeInterval(LCLeaderboardVersionChangeInterval versionChangeInterval) {
|
public async Task<LCLeaderboard> UpdateVersionChangeInterval(LCLeaderboardVersionChangeInterval versionChangeInterval) {
|
||||||
Dictionary<string, object> data = new Dictionary<string, object> {
|
Dictionary<string, object> data = new Dictionary<string, object> {
|
||||||
{ "versionChangeInterval", versionChangeInterval.ToString().ToLower() }
|
{ "versionChangeInterval", versionChangeInterval.ToString().ToLower() }
|
||||||
|
|
|
@ -4,19 +4,34 @@ using System.Collections.ObjectModel;
|
||||||
using LeanCloud.Storage.Internal.Object;
|
using LeanCloud.Storage.Internal.Object;
|
||||||
|
|
||||||
namespace LeanCloud.Storage {
|
namespace LeanCloud.Storage {
|
||||||
|
/// <summary>
|
||||||
|
/// LCRanking represents the rankings of LCLeaderboard.
|
||||||
|
/// </summary>
|
||||||
public class LCRanking {
|
public class LCRanking {
|
||||||
|
/// <summary>
|
||||||
|
/// The ranking.
|
||||||
|
/// </summary>
|
||||||
public int Rank {
|
public int Rank {
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The user of this LCRanking.
|
||||||
|
/// </summary>
|
||||||
public LCUser User {
|
public LCUser User {
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The statistic name of this LCRanking.
|
||||||
|
/// </summary>
|
||||||
public string StatisticName {
|
public string StatisticName {
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The value of this LCRanking.
|
||||||
|
/// </summary>
|
||||||
public double Value {
|
public double Value {
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,27 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace LeanCloud.Storage {
|
namespace LeanCloud.Storage {
|
||||||
|
/// <summary>
|
||||||
|
/// LCStatistic represents the statistic of LeanCloud leaderboard.
|
||||||
|
/// </summary>
|
||||||
public class LCStatistic {
|
public class LCStatistic {
|
||||||
|
/// <summary>
|
||||||
|
/// The name of this LCStatistic.
|
||||||
|
/// </summary>
|
||||||
public string Name {
|
public string Name {
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The value of this LCStatistic.
|
||||||
|
/// </summary>
|
||||||
public double Value {
|
public double Value {
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The version of this LCStatistic.
|
||||||
|
/// </summary>
|
||||||
public int Version {
|
public int Version {
|
||||||
get; internal set;
|
get; internal set;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue