Actually fix deduplicating arguments (#249)

This commit is contained in:
spiral 2020-11-25 17:18:56 -05:00
parent fde7e4d3cc
commit 61793f5fe2
No known key found for this signature in database
GPG Key ID: 00C26F208D3FCCAB
2 changed files with 4 additions and 2 deletions

View File

@ -322,6 +322,7 @@ namespace PluralKit.Bot
var members = (await ctx.ParseMemberList(ctx.System.Id))
.Select(m => m.Id)
.Distinct()
.ToList();
await using var conn = await _db.Obtain();
@ -329,6 +330,7 @@ namespace PluralKit.Bot
var existingMembersInGroup = (await conn.QueryMemberList(target.System,
new DatabaseViewsExt.MemberListQueryOptions {GroupFilter = target.Id}))
.Select(m => m.Id.Value)
.Distinct()
.ToHashSet();
List<MemberId> toAction;
@ -337,7 +339,6 @@ namespace PluralKit.Bot
{
toAction = members
.Where(m => !existingMembersInGroup.Contains(m.Value))
.Distinct()
.ToList();
await _repo.AddMembersToGroup(conn, target.Id, toAction);
}
@ -345,7 +346,6 @@ namespace PluralKit.Bot
{
toAction = members
.Where(m => existingMembersInGroup.Contains(m.Value))
.Distinct()
.ToList();
await _repo.RemoveMembersFromGroup(conn, target.Id, toAction);
}

View File

@ -26,11 +26,13 @@ namespace PluralKit.Bot
var groups = (await ctx.ParseGroupList(ctx.System.Id))
.Select(g => g.Id)
.Distinct()
.ToList();
await using var conn = await _db.Obtain();
var existingGroups = (await _repo.GetMemberGroups(conn, target.Id).ToListAsync())
.Select(g => g.Id)
.Distinct()
.ToList();
List<GroupId> toAction;