feat: Project preready

This commit is contained in:
ereshk1gal
2025-10-01 01:42:16 +03:00
parent 06cb66624c
commit 504f03bd32
37 changed files with 1671 additions and 147 deletions

View File

@@ -2,6 +2,7 @@ using LctMonolith.Database.UnitOfWork;
using LctMonolith.Models.Database;
using LctMonolith.Services.Models;
using Microsoft.EntityFrameworkCore;
using Serilog;
namespace LctMonolith.Services;
@@ -15,16 +16,26 @@ public class AnalyticsService : IAnalyticsService
public async Task<AnalyticsSummary> GetSummaryAsync(CancellationToken ct = default)
{
var totalUsers = await _uow.Users.Query().CountAsync(ct);
var totalMissions = await _uow.Missions.Query().CountAsync(ct);
var totalStoreItems = await _uow.StoreItems.Query().CountAsync(ct);
var totalExperience = await _uow.Users.Query().SumAsync(u => (long)u.Experience, ct);
return new AnalyticsSummary
try
{
TotalUsers = totalUsers,
TotalMissions = totalMissions,
TotalStoreItems = totalStoreItems,
TotalExperience = totalExperience
};
var totalUsers = await _uow.Users.Query().CountAsync(ct);
var totalMissions = await _uow.Missions.Query().CountAsync(ct);
var totalStoreItems = await _uow.StoreItems.Query().CountAsync(ct);
var totalExperience = await _uow.Players.Query().SumAsync(p => (long)p.Experience, ct);
var completedMissions = await _uow.PlayerMissions.Query(pm => pm.Completed != null).CountAsync(ct);
return new AnalyticsSummary
{
TotalUsers = totalUsers,
TotalMissions = totalMissions,
TotalStoreItems = totalStoreItems,
TotalExperience = totalExperience,
CompletedMissions = completedMissions
};
}
catch (Exception ex)
{
Log.Error(ex, "Failed to build analytics summary");
throw;
}
}
}