Skip to content

Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.

fix: update monthlyCount() callers to pass UsageType enum

Paulo Castellano8adbee627633
diff --git a/app/Http/Controllers/App/Settings/UsageController.php b/app/Http/Controllers/App/Settings/UsageController.php
index 474a4af0b..595a27159 100644
--- a/app/Http/Controllers/App/Settings/UsageController.php
+++ b/app/Http/Controllers/App/Settings/UsageController.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Http\Controllers\App\Settings;
+use App\Enums\Ai\UsageType;
use App\Features\AiImagesLimit;
use App\Features\AiVideosLimit;
use App\Features\DataRetentionDays;
@@ -47,9 +48,9 @@ class UsageController extends Controller
'socialAccountLimit' => Feature::for($account)->value(SocialAccountLimit::class),
'memberCount' => $totalMembers,
'memberLimit' => Feature::for($account)->value(MemberLimit::class),
- 'aiImagesUsed' => AiUsageLog::monthlyCount($account->id, 'image'),
+ 'aiImagesUsed' => AiUsageLog::monthlyCount($account->id, UsageType::Image),
'aiImagesLimit' => Feature::for($account)->value(AiImagesLimit::class),
- 'aiVideosUsed' => AiUsageLog::monthlyCount($account->id, 'video'),
+ 'aiVideosUsed' => AiUsageLog::monthlyCount($account->id, UsageType::Video),
'aiVideosLimit' => Feature::for($account)->value(AiVideosLimit::class),
'dataRetentionDays' => Feature::for($account)->value(DataRetentionDays::class),
],
diff --git a/tests/Feature/AiUsageLogTest.php b/tests/Feature/AiUsageLogTest.php
index d8d8c083f..0eb7bb6c9 100644
--- a/tests/Feature/AiUsageLogTest.php
+++ b/tests/Feature/AiUsageLogTest.php
@@ -3,6 +3,7 @@
declare(strict_types=1);
use App\Enums\Ai\Intent;
+use App\Enums\Ai\UsageType;
use App\Models\Account;
use App\Models\AiUsageLog;
use App\Models\Workspace;
@@ -22,9 +23,9 @@ test('monthly count returns correct count for account and type', function () {
'workspace_id' => $workspace->id,
]);
- expect(AiUsageLog::monthlyCount($account->id, 'image'))->toBe(3);
- expect(AiUsageLog::monthlyCount($account->id, 'video'))->toBe(2);
- expect(AiUsageLog::monthlyCount($account->id, 'audio'))->toBe(0);
+ expect(AiUsageLog::monthlyCount($account->id, UsageType::Image))->toBe(3);
+ expect(AiUsageLog::monthlyCount($account->id, UsageType::Video))->toBe(2);
+ expect(AiUsageLog::monthlyCount($account->id, UsageType::Audio))->toBe(0);
});
test('monthly count excludes logs from other months', function () {
@@ -42,7 +43,7 @@ test('monthly count excludes logs from other months', function () {
'created_at' => now()->subMonth(),
]);
- expect(AiUsageLog::monthlyCount($account->id, 'image'))->toBe(1);
+ expect(AiUsageLog::monthlyCount($account->id, UsageType::Image))->toBe(1);
});
test('monthly count excludes logs from other accounts', function () {
@@ -61,7 +62,7 @@ test('monthly count excludes logs from other accounts', function () {
'workspace_id' => $otherWorkspace->id,
]);
- expect(AiUsageLog::monthlyCount($account->id, 'image'))->toBe(1);
+ expect(AiUsageLog::monthlyCount($account->id, UsageType::Image))->toBe(1);
});
test('intent detector detects video intent', function () {