Global leaderboards and specific statuses

This commit is contained in:
Basique Evangelist 2020-06-13 02:42:54 +03:00
parent 0b40235c9b
commit eae44695e7
Signed by untrusted user: BasiqueEvangelist
GPG Key ID: B370219149301706
2 changed files with 3 additions and 2 deletions

View File

@ -18,6 +18,7 @@ namespace JetKarmaBot.Commands
var currentLocale = ctx.GetFeature<Locale>(); var currentLocale = ctx.GetFeature<Locale>();
var asker = ctx.EventArgs.Message.From; var asker = ctx.EventArgs.Message.From;
var awardTypeName = ctx.Command.Parameters.FirstOrDefault(); var awardTypeName = ctx.Command.Parameters.FirstOrDefault();
bool isPrivate = ctx.EventArgs.Message.Chat.Type == Telegram.Bot.Types.Enums.ChatType.Private;
if (string.IsNullOrWhiteSpace(awardTypeName)) if (string.IsNullOrWhiteSpace(awardTypeName))
awardTypeName = "star"; awardTypeName = "star";
@ -30,7 +31,7 @@ namespace JetKarmaBot.Commands
await ctx.SendMessage(string.Format(currentLocale["jetkarmabot.leaderboard.specifictext"], awardType.Symbol) + "\n" + string.Join('\n', await ctx.SendMessage(string.Format(currentLocale["jetkarmabot.leaderboard.specifictext"], awardType.Symbol) + "\n" + string.Join('\n',
await Task.WhenAll((await db.Awards await Task.WhenAll((await db.Awards
.Where(x => x.ChatId == ctx.EventArgs.Message.Chat.Id && x.AwardTypeId == awardTypeId) .Where(x => (x.ChatId == ctx.EventArgs.Message.Chat.Id || isPrivate) && x.AwardTypeId == awardTypeId)
.GroupBy(x => x.ToId) .GroupBy(x => x.ToId)
.Select(x => new { UserId = x.Key, Amount = x.Sum(y => y.Amount) }) .Select(x => new { UserId = x.Key, Amount = x.Sum(y => y.Amount) })
.OrderByDescending(x => x.Amount) .OrderByDescending(x => x.Amount)

View File

@ -57,7 +57,7 @@ namespace JetKarmaBot.Commands
await db.Awards.Where( await db.Awards.Where(
x => x.AwardTypeId == awardTypeId x => x.AwardTypeId == awardTypeId
&& x.ToId == asker.Id && x.ToId == asker.Id
&& x.ChatId == ctx.EventArgs.Message.Chat.Id) && (x.ChatId == ctx.EventArgs.Message.Chat.Id || isPrivate))
.SumAsync(x => x.Amount), awardType.Symbol); .SumAsync(x => x.Amount), awardType.Symbol);
} }