initial commit

This commit is contained in:
Yui
2025-11-26 16:50:06 -03:00
commit 5644aa0ebf
47 changed files with 800 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
using Application.Interfaces.Services;
using Domain.Entities;
using GreenDonut.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace GraphQLTEST.GraphQL.DataLoaders;
public class KillsByUserDataLoader : GroupedDataLoader<int, Kill>{
private readonly IServiceProvider _serviceProvider;
public KillsByUserDataLoader(
IServiceProvider serviceProvider,
IBatchScheduler batchScheduler,
DataLoaderOptions options): base(batchScheduler, options){
_serviceProvider = serviceProvider;
}
protected override async Task<ILookup<int, Kill>> LoadGroupedBatchAsync(IReadOnlyList<int> keys, CancellationToken cancellationToken)
{
await using var scope = _serviceProvider.CreateAsyncScope();
var service = scope.ServiceProvider.GetRequiredService<IKillService>();
return await service.GetKillsByUserId(keys)
.ToAsyncEnumerable()
.ToLookupAsync(k => k.UserId, cancellationToken: cancellationToken);
}
}