Skip to content

Commit

Permalink
Call AsEnumerable to prevent expression -> query conversion
Browse files Browse the repository at this point in the history
Questionable in terms of performance. We don't want DB to yield results we don't need, even if it is lazy.

TODO: consider not-null column and set indefinite expiration to MinValue?
  • Loading branch information
oliverbooth committed Mar 9, 2022
1 parent 520c55c commit 81c4d1f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Hammer/Services/UserTrackingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ private async Task UpdateFromDatabaseAsync()
await using var context = scope.ServiceProvider.GetRequiredService<HammerContext>();

foreach (IGrouping<ulong, TrackedUser> trackedUsers in
context.TrackedUsers.Where(u => u.ExpirationTime == null || u.ExpirationTime > DateTimeOffset.UtcNow)
context.TrackedUsers.AsEnumerable()
.Where(u => u.ExpirationTime == null || u.ExpirationTime > DateTimeOffset.UtcNow)
.GroupBy(u => u.GuildId))
{
DiscordGuild guild = await _discordClient.GetGuildAsync(trackedUsers.Key);
Expand Down

0 comments on commit 81c4d1f

Please sign in to comment.