update
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
|
||||
using BackOffice.BFF.NetworkMembership.Protobuf;
|
||||
|
||||
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkHistory;
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkStatistics;
|
||||
|
||||
public class GetNetworkStatisticsQuery : IRequest<GetNetworkStatisticsResponseDto>
|
||||
{
|
||||
// No parameters - returns overall statistics
|
||||
}
|
||||
@@ -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>();
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
|
||||
using BackOffice.BFF.NetworkMembership.Protobuf;
|
||||
|
||||
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetNetworkTree;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using CMSMicroservice.Protobuf.Protos.NetworkMembership;
|
||||
using BackOffice.BFF.NetworkMembership.Protobuf;
|
||||
|
||||
namespace BackOffice.BFF.Application.NetworkMembershipCQ.Queries.GetUserNetworkInfo;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user