mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2025-08-16 21:31:45 +02:00
.config
.run
.workdir
Agent
Common
Controller
Phantom.Controller
Phantom.Controller.Database
Converters
Entities
Factories
Repositories
AuditLogRepository.Writer.cs
AuditLogRepository.cs
EventLogRepository.cs
PermissionRepository.cs
RoleRepository.cs
UserRepository.cs
UserRoleRepository.cs
ApplicationDbContext.cs
DatabaseMigrator.cs
IDbContextProvider.cs
ILazyDbContext.cs
Phantom.Controller.Database.csproj
Phantom.Controller.Database.Postgres
Phantom.Controller.Minecraft
Phantom.Controller.Services
Docker
Utils
Web
.dockerignore
.gitattributes
.gitignore
AddMigration.bat
AddMigration.sh
Directory.Build.props
Directory.Build.targets
Dockerfile
LICENSE
Packages.props
PhantomPanel.sln
README.md
global.json
31 lines
1.0 KiB
C#
31 lines
1.0 KiB
C#
using System.Collections.Immutable;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Phantom.Common.Data.Web.AuditLog;
|
|
using Phantom.Utils.Collections;
|
|
|
|
namespace Phantom.Controller.Database.Repositories;
|
|
|
|
public sealed partial class AuditLogRepository {
|
|
private readonly ILazyDbContext db;
|
|
|
|
public AuditLogRepository(ILazyDbContext db) {
|
|
this.db = db;
|
|
}
|
|
|
|
public Task<ImmutableArray<AuditLogItem>> GetMostRecentItems(int count, CancellationToken cancellationToken) {
|
|
return db.Ctx
|
|
.AuditLog
|
|
.Include(static entity => entity.User)
|
|
.AsQueryable()
|
|
.OrderByDescending(static entity => entity.UtcTime)
|
|
.Take(count)
|
|
.AsAsyncEnumerable()
|
|
.Select(static entity => new AuditLogItem(entity.UtcTime, entity.UserGuid, entity.User?.Name, entity.EventType, entity.SubjectType, entity.SubjectId, entity.Data?.RootElement.ToString()))
|
|
.ToImmutableArrayAsync(cancellationToken);
|
|
}
|
|
|
|
public ItemWriter Writer(Guid? currentUserGuid) {
|
|
return new ItemWriter(db, currentUserGuid);
|
|
}
|
|
}
|