Skip to content

Commit 21decb5

Browse files
fix: fixing possible duplicate insertion
Getting errors in the log for duplicate insertions into the TwitchUser table. This is the only place here I can see duplicates.
1 parent 99382e0 commit 21decb5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Nullinside.Api.TwitchBot/Model/NullinsideContextExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ private static async Task<int> UpdateOAuthInDatabase(this INullinsideContext db,
161161
/// <param name="stoppingToken">The stopping token.</param>
162162
public static async Task SaveTwitchBans(this INullinsideContext db, string channelId,
163163
IEnumerable<(string Id, string Username)> bannedUsers, string reason, CancellationToken stoppingToken = new()) {
164-
List<string> banUserIds = bannedUsers.Select(b => b.Id).ToList();
164+
List<string> banUserIds = bannedUsers.Select(b => b.Id).ToHashSet().ToList();
165165
HashSet<string?> existingUsers = db.TwitchUser
166166
.AsNoTracking()
167167
.Where(u => null != u.TwitchId && banUserIds.Contains(u.TwitchId))

0 commit comments

Comments
 (0)