feat: show account storage usage
CI and Deploy / test (push) Successful in 2m37s
CI and Deploy / deploy (push) Successful in 58s

This commit is contained in:
cesnimda
2026-07-31 00:10:15 +02:00
parent 9f16a5675a
commit 10d548f799
3 changed files with 21 additions and 3 deletions
@@ -22,7 +22,7 @@ public sealed class AiUsageController : ControllerBase
}
public sealed record UsagePeriodDto(int Calls, long InputCharacters, long OutputCharacters, long EstimatedTokens);
public sealed record UsageDto(UsagePeriodDto CurrentMonth, UsagePeriodDto AllTime, string Plan, int MonthlyCallLimit, long MonthlyTokenLimit);
public sealed record UsageDto(UsagePeriodDto CurrentMonth, UsagePeriodDto AllTime, string Plan, int MonthlyCallLimit, long MonthlyTokenLimit, long StorageUsedBytes, long StorageLimitBytes);
[HttpGet]
public async Task<ActionResult<UsageDto>> Get(CancellationToken cancellationToken)
@@ -38,7 +38,9 @@ public sealed class AiUsageController : ControllerBase
await SumAsync(_db.AiInteractions.Where(x => x.OwnerUserId == user.Id), cancellationToken),
entitlements.AdvancedAi ? "premium" : "free",
entitlements.MonthlyAiCalls,
entitlements.MonthlyAiTokens));
entitlements.MonthlyAiTokens,
await _db.Attachments.Where(x => x.JobApplication.OwnerUserId == user.Id).SumAsync(x => (long?)x.FileSize, cancellationToken) ?? 0,
entitlements.StorageBytes));
}
private static async Task<UsagePeriodDto> SumAsync(IQueryable<AiInteraction> query, CancellationToken cancellationToken)