Using new .Chunk and .DistinctBy Linq Extensions

This commit is contained in:
Kwoth
2021-12-24 02:10:21 +01:00
parent 594a3b1f97
commit 26ee6ce4d3
6 changed files with 14 additions and 45 deletions

View File

@@ -30,7 +30,7 @@ public partial class Administration
var grp = 0;
var results = input
.GroupBy(x => grp++ / 2)
.Chunk(input.Length / 2)
.Select(async x =>
{
var inputRoleStr = x.First();

View File

@@ -47,8 +47,7 @@ public class PruneService : INService
if (bulkDeletable.Count > 0)
await Task.WhenAll(Task.Delay(1000), channel.DeleteMessagesAsync(bulkDeletable)).ConfigureAwait(false);
var i = 0;
foreach (var group in singleDeletable.GroupBy(x => ++i / (singleDeletable.Count / 5)))
foreach (var group in singleDeletable.Chunk(5))
await Task.WhenAll(Task.Delay(1000), Task.WhenAll(group.Select(x => x.DeleteAsync()))).ConfigureAwait(false);
//this isn't good, because this still work as if i want to remove only specific user's messages from the last