Add editorconfig and analyzers, format backend code
This commit is contained in:
@@ -4,35 +4,34 @@ using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Contracts;
|
||||
using Musify.Application.Mixes;
|
||||
|
||||
namespace Musify.Infrastructure.Jobs
|
||||
namespace Musify.Infrastructure.Jobs;
|
||||
|
||||
public class DailyMixGenerationJob(
|
||||
IDatabase database,
|
||||
IMediator mediator,
|
||||
ILogger<DailyMixGenerationJob> logger)
|
||||
{
|
||||
public class DailyMixGenerationJob(
|
||||
IDatabase database,
|
||||
IMediator mediator,
|
||||
ILogger<DailyMixGenerationJob> logger)
|
||||
public async Task RunAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
public async Task RunAsync(CancellationToken cancellationToken)
|
||||
var userIds = await database.ListeningHistories
|
||||
.AsNoTracking()
|
||||
.Where(history => history.IsCounted)
|
||||
.Select(history => history.UserId)
|
||||
.Distinct()
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
logger.LogInformation("Starting daily mix generation for {Count} users", userIds.Count);
|
||||
|
||||
foreach (var userId in userIds)
|
||||
{
|
||||
var userIds = await database.ListeningHistories
|
||||
.AsNoTracking()
|
||||
.Where(history => history.IsCounted)
|
||||
.Select(history => history.UserId)
|
||||
.Distinct()
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
logger.LogInformation("Starting daily mix generation for {Count} users", userIds.Count);
|
||||
|
||||
foreach (var userId in userIds)
|
||||
var result = await mediator.Send(new GenerateMixesForUserCommand(userId), cancellationToken);
|
||||
if (result.IsError)
|
||||
{
|
||||
var result = await mediator.Send(new GenerateMixesForUserCommand(userId), cancellationToken);
|
||||
if (result.IsError)
|
||||
{
|
||||
logger.LogWarning("Failed to generate mixes for user {UserId}: {Error}",
|
||||
userId, result.FirstError.Description);
|
||||
}
|
||||
logger.LogWarning("Failed to generate mixes for user {UserId}: {Error}",
|
||||
userId, result.FirstError.Description);
|
||||
}
|
||||
|
||||
logger.LogInformation("Finished daily mix generation");
|
||||
}
|
||||
|
||||
logger.LogInformation("Finished daily mix generation");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user