mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
[reputation] Add rating.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Kruzya.TelegramBot.Core.Extensions;
|
||||
using Kruzya.TelegramBot.Core.Data;
|
||||
using Kruzya.TelegramBot.Core.Extensions;
|
||||
using Kruzya.TelegramBot.Core.Service;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Telegram.Bot.Types;
|
||||
@@ -54,6 +55,16 @@ public class ReputationService : IReputation
|
||||
return Math.Round(senderValue == 0 ? 1 : Math.Sqrt(senderValue), 2);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<IReputationEntity>> GetChatRatingAsync(Chat chat, int limit = 10, int offset = 0)
|
||||
{
|
||||
return await _reputationContext.UserReputation
|
||||
.Where(r => r.ChatId == chat.Id && r.Value != 0D)
|
||||
.OrderByDescending(r => r.Value)
|
||||
.Skip(offset)
|
||||
.Take(limit)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
private async Task<UserReputation?> FindUserReputation(Chat chat, User user)
|
||||
{
|
||||
return await _reputationContext.UserReputation.SingleOrDefaultAsync(
|
||||
|
||||
Reference in New Issue
Block a user