feat: 구독 페이지에 일간 API 호출 사용량 추적 추가
- SubscriptionService::usage()에 api_calls 섹션 추가 - api_request_logs 테이블에서 테넌트별 일간 API 호출 수 집계 - 기본 일간 제한: 10,000회 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\ApiRequestLog;
|
||||
use App\Models\Tenants\DataExport;
|
||||
use App\Models\Tenants\Payment;
|
||||
use App\Models\Tenants\Plan;
|
||||
@@ -319,6 +320,13 @@ public function usage(): array
|
||||
$storageUsed = $tenant->storage_used ?? 0;
|
||||
$storageLimit = $tenant->storage_limit ?? 0;
|
||||
|
||||
// API 호출 수 (일간 - 로그는 1일 보관)
|
||||
$apiCallsUsed = ApiRequestLog::where('tenant_id', $tenantId)
|
||||
->whereDate('created_at', now()->toDateString())
|
||||
->count();
|
||||
// 기본 일간 API 호출 제한 (10,000회)
|
||||
$apiCallsLimit = 10000;
|
||||
|
||||
// 구독 정보
|
||||
$subscription = $tenant->subscription;
|
||||
$remainingDays = null;
|
||||
@@ -342,6 +350,11 @@ public function usage(): array
|
||||
'limit_formatted' => $tenant->getStorageLimitFormatted(),
|
||||
'percentage' => $storageLimit > 0 ? round(($storageUsed / $storageLimit) * 100, 1) : 0,
|
||||
],
|
||||
'api_calls' => [
|
||||
'used' => $apiCallsUsed,
|
||||
'limit' => $apiCallsLimit,
|
||||
'percentage' => $apiCallsLimit > 0 ? round(($apiCallsUsed / $apiCallsLimit) * 100, 1) : 0,
|
||||
],
|
||||
'subscription' => [
|
||||
'plan' => $planName,
|
||||
'status' => $subscription?->status,
|
||||
|
||||
Reference in New Issue
Block a user