This commit is contained in:
masoodafar-web
2025-12-02 03:32:26 +03:30
parent 6cd29e8b26
commit c9dab944fa
56 changed files with 1181 additions and 710 deletions

View File

@@ -1,4 +1,4 @@
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
using BackOffice.BFF.NetworkMembership.Protobuf;
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkHistory;

View File

@@ -0,0 +1,6 @@
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkStatistics;
public class GetNetworkStatisticsQuery : IRequest<GetNetworkStatisticsResponseDto>
{
// No parameters - returns overall statistics
}

View File

@@ -0,0 +1,22 @@
using BackOffice.BFF.NetworkMembership.Protobuf;
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkStatistics;
public class GetNetworkStatisticsQueryHandler : IRequestHandler<GetNetworkStatisticsQuery, GetNetworkStatisticsResponseDto>
{
private readonly IApplicationContractContext _context;
public GetNetworkStatisticsQueryHandler(IApplicationContractContext context)
{
_context = context;
}
public async Task<GetNetworkStatisticsResponseDto> Handle(GetNetworkStatisticsQuery request, CancellationToken cancellationToken)
{
var grpcRequest = new GetNetworkStatisticsRequest();
var response = await _context.NetworkMemberships.GetNetworkStatisticsAsync(grpcRequest, cancellationToken: cancellationToken);
return response.Adapt<GetNetworkStatisticsResponseDto>();
}
}

View File

@@ -0,0 +1,38 @@
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkStatistics;
public class GetNetworkStatisticsResponseDto
{
public int TotalMembers { get; set; }
public int ActiveMembers { get; set; }
public int LeftLegCount { get; set; }
public int RightLegCount { get; set; }
public double LeftPercentage { get; set; }
public double RightPercentage { get; set; }
public double AverageDepth { get; set; }
public int MaxDepth { get; set; }
public List<LevelDistributionModel> LevelDistribution { get; set; } = new();
public List<MonthlyGrowthModel> MonthlyGrowth { get; set; } = new();
public List<TopNetworkUserModel> TopUsers { get; set; } = new();
}
public class LevelDistributionModel
{
public int Level { get; set; }
public int Count { get; set; }
}
public class MonthlyGrowthModel
{
public string Month { get; set; } = string.Empty;
public int NewMembers { get; set; }
}
public class TopNetworkUserModel
{
public int Rank { get; set; }
public long UserId { get; set; }
public string UserName { get; set; } = string.Empty;
public int TotalChildren { get; set; }
public int LeftCount { get; set; }
public int RightCount { get; set; }
}

View File

@@ -1,4 +1,4 @@
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
using BackOffice.BFF.NetworkMembership.Protobuf;
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkTree;

View File

@@ -1,4 +1,4 @@
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
using BackOffice.BFF.NetworkMembership.Protobuf;
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetUserNetworkInfo;