feat: initialize database schema and implement core Radius entities, EF context, and account enforcement service.
Build and Push Docker Image to Gitea Container Registry / build-and-push (push) Successful in 1m12s
Build and Push Docker Image to Gitea Container Registry / build-and-push (push) Successful in 1m12s
This commit is contained in:
@@ -175,25 +175,27 @@ public class RadiusService : IRadiusService
|
||||
.Where(rc => rc.Attribute == "Cleartext-Password")
|
||||
.ToDictionaryAsync(rc => rc.Username, rc => rc.Value);
|
||||
|
||||
// Group accounting data by username
|
||||
// Group accounting data by username (for session time and connection status)
|
||||
var acctStats = await _db.RadAcct
|
||||
.GroupBy(ra => ra.Username)
|
||||
.Select(g => new
|
||||
{
|
||||
Username = g.Key,
|
||||
TotalInput = g.Sum(x => x.AcctInputOctets ?? 0),
|
||||
TotalOutput = g.Sum(x => x.AcctOutputOctets ?? 0),
|
||||
TotalSessionTime = g.Sum(x => x.AcctSessionTime ?? 0),
|
||||
IsConnected = g.Any(x => x.AcctStopTime == null)
|
||||
})
|
||||
.ToDictionaryAsync(g => g.Username);
|
||||
|
||||
// Fetch data usage from the new dedicated table
|
||||
var dataUsage = await _db.GuestDataUsage.ToDictionaryAsync(du => du.Username);
|
||||
|
||||
var result = new List<UserUsageDto>();
|
||||
|
||||
foreach (var p in profiles)
|
||||
{
|
||||
passwords.TryGetValue(p.Username, out var pwd);
|
||||
acctStats.TryGetValue(p.Username, out var acct);
|
||||
dataUsage.TryGetValue(p.Username, out var usage);
|
||||
|
||||
result.Add(new UserUsageDto
|
||||
{
|
||||
@@ -205,8 +207,8 @@ public class RadiusService : IRadiusService
|
||||
SessionTimeMinutes = p.SessionTimeMinutes,
|
||||
DataLimitMb = p.DataLimitMb,
|
||||
Status = p.Status,
|
||||
TotalInputOctets = acct?.TotalInput ?? 0,
|
||||
TotalOutputOctets = acct?.TotalOutput ?? 0,
|
||||
TotalInputOctets = usage?.TotalInputOctets ?? 0,
|
||||
TotalOutputOctets = usage?.TotalOutputOctets ?? 0,
|
||||
TotalSessionTimeSeconds = acct?.TotalSessionTime ?? 0,
|
||||
IsCurrentlyConnected = acct?.IsConnected ?? false
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user