Merge pull request #10617 from barronpm/query-improvements

Query Improvements
This commit is contained in:
Claus Vium 2023-11-23 22:31:01 +01:00 committed by GitHub
commit f19492c1de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 17 deletions

View File

@ -68,7 +68,6 @@ namespace Jellyfin.Server.Implementations.Activity
Date = entity.DateCreated,
Severity = entity.LogSeverity
})
.AsQueryable()
.ToListAsync()
.ConfigureAwait(false));
}
@ -80,11 +79,10 @@ namespace Jellyfin.Server.Implementations.Activity
var dbContext = await _provider.CreateDbContextAsync().ConfigureAwait(false);
await using (dbContext.ConfigureAwait(false))
{
var entries = dbContext.ActivityLogs
.Where(entry => entry.DateCreated <= startDate);
dbContext.RemoveRange(entries);
await dbContext.SaveChangesAsync().ConfigureAwait(false);
await dbContext.ActivityLogs
.Where(entry => entry.DateCreated <= startDate)
.ExecuteDeleteAsync()
.ConfigureAwait(false);
}
}

View File

@ -58,19 +58,10 @@ namespace Jellyfin.Server.Implementations.Security
var dbContext = await _dbProvider.CreateDbContextAsync().ConfigureAwait(false);
await using (dbContext.ConfigureAwait(false))
{
var key = await dbContext.ApiKeys
await dbContext.ApiKeys
.Where(apiKey => apiKey.AccessToken == accessToken)
.FirstOrDefaultAsync()
.ExecuteDeleteAsync()
.ConfigureAwait(false);
if (key is null)
{
return;
}
dbContext.Remove(key);
await dbContext.SaveChangesAsync().ConfigureAwait(false);
}
}
}