From 5e4183acfa75c6f3a42758f075065bf3a6c02c8f Mon Sep 17 00:00:00 2001 From: Andriy <30056636+West14@users.noreply.github.com> Date: Sat, 29 Jul 2023 13:51:35 +0300 Subject: [PATCH] [reputation] drop dbg_migrate command --- modules/Reputation/Handler/Debug.cs | 65 ----------------------------- 1 file changed, 65 deletions(-) delete mode 100644 modules/Reputation/Handler/Debug.cs diff --git a/modules/Reputation/Handler/Debug.cs b/modules/Reputation/Handler/Debug.cs deleted file mode 100644 index 5b4b31c..0000000 --- a/modules/Reputation/Handler/Debug.cs +++ /dev/null @@ -1,65 +0,0 @@ -using BotFramework; -using BotFramework.Attributes; -using BotFramework.Enums; -using Kruzya.TelegramBot.Core.Data; -using Kruzya.TelegramBot.Core.Service; -using Microsoft.EntityFrameworkCore; -using West.TelegramBot.Reputation.Data; - -namespace West.TelegramBot.Reputation.Handler; - -public class Debug : BotEventHandler -{ - private readonly CoreContext _coreContext; - private readonly ReputationContext _reputationContext; - private readonly UserService _userService; - - - public Debug(CoreContext coreContext, ReputationContext reputationContext, UserService userService) - { - _coreContext = coreContext; - _reputationContext = reputationContext; - _userService = userService; - } - - [InChat(InChat.Public)] - [Command("dbg_migrate", CommandParseMode.Both)] - public async Task HandleMigrate() - { - if (!_userService.IsUserSuper(From)) - { - return; - } - - var reputationValues = _coreContext.UserValues.AsNoTracking() - .Where(value => value.Name == "reputation").Include(v => v.BotUser); - - foreach (var reputationValue in reputationValues) - { - var value = reputationValue.GetValue(); - if (value == 0D) - { - continue; - } - - var userReputation = new UserReputation - { - ChatId = reputationValue.BotUser.ChatId, - UserId = reputationValue.BotUser.UserId, - Value = value - }; - - var repList = _reputationContext.UserReputation; - if (repList.Contains(userReputation)) - { - repList.Update(userReputation); - } - else - { - repList.Add(userReputation); - } - } - - await _reputationContext.SaveChangesAsync(); - } -} \ No newline at end of file