diff --git a/composer.lock b/composer.lock index 53faf5cd..7619429d 100644 --- a/composer.lock +++ b/composer.lock @@ -280,16 +280,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.213.1", + "version": "3.214.0", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "7d361a532ccb7c6a640fdfd4be23980c0fa60fd1" + "reference": "a2eacf8c1b55de4733f4cfc315da38f1d4c66501" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/7d361a532ccb7c6a640fdfd4be23980c0fa60fd1", - "reference": "7d361a532ccb7c6a640fdfd4be23980c0fa60fd1", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/a2eacf8c1b55de4733f4cfc315da38f1d4c66501", + "reference": "a2eacf8c1b55de4733f4cfc315da38f1d4c66501", "shasum": "" }, "require": { @@ -365,9 +365,9 @@ "support": { "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80", "issues": "https://github.com/aws/aws-sdk-php/issues", - "source": "https://github.com/aws/aws-sdk-php/tree/3.213.1" + "source": "https://github.com/aws/aws-sdk-php/tree/3.214.0" }, - "time": "2022-03-15T20:28:59+00:00" + "time": "2022-03-16T19:00:00+00:00" }, { "name": "bacon/bacon-qr-code", @@ -936,16 +936,16 @@ }, { "name": "composer/semver", - "version": "3.3.0", + "version": "3.3.1", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "f79c90ad4e9b41ac4dfc5d77bf398cf61fbd718b" + "reference": "5d8e574bb0e69188786b8ef77d43341222a41a71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/f79c90ad4e9b41ac4dfc5d77bf398cf61fbd718b", - "reference": "f79c90ad4e9b41ac4dfc5d77bf398cf61fbd718b", + "url": "https://api.github.com/repos/composer/semver/zipball/5d8e574bb0e69188786b8ef77d43341222a41a71", + "reference": "5d8e574bb0e69188786b8ef77d43341222a41a71", "shasum": "" }, "require": { @@ -997,7 +997,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.3.0" + "source": "https://github.com/composer/semver/tree/3.3.1" }, "funding": [ { @@ -1013,7 +1013,7 @@ "type": "tidelift" } ], - "time": "2022-03-15T08:35:57+00:00" + "time": "2022-03-16T11:22:07+00:00" }, { "name": "composer/xdebug-handler", @@ -4475,7 +4475,7 @@ "dist": { "type": "path", "url": "../../PhpstormProjects/subscription", - "reference": "11b499ba967427de10ff5d18a86f3b6676039875" + "reference": "5bed67cb6893be3e64f4b867428a4412724a2eff" }, "require": { "friendsofphp/php-cs-fixer": "^3.6.0", @@ -7370,16 +7370,16 @@ }, { "name": "react/event-loop", - "version": "v1.2.0", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/reactphp/event-loop.git", - "reference": "be6dee480fc4692cec0504e65eb486e3be1aa6f2" + "reference": "187fb56f46d424afb6ec4ad089269c72eec2e137" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/event-loop/zipball/be6dee480fc4692cec0504e65eb486e3be1aa6f2", - "reference": "be6dee480fc4692cec0504e65eb486e3be1aa6f2", + "url": "https://api.github.com/repos/reactphp/event-loop/zipball/187fb56f46d424afb6ec4ad089269c72eec2e137", + "reference": "187fb56f46d424afb6ec4ad089269c72eec2e137", "shasum": "" }, "require": { @@ -7432,7 +7432,7 @@ ], "support": { "issues": "https://github.com/reactphp/event-loop/issues", - "source": "https://github.com/reactphp/event-loop/tree/v1.2.0" + "source": "https://github.com/reactphp/event-loop/tree/v1.3.0" }, "funding": [ { @@ -7444,7 +7444,7 @@ "type": "github" } ], - "time": "2021-07-11T12:31:24+00:00" + "time": "2022-03-17T11:10:22+00:00" }, { "name": "react/http", @@ -14379,16 +14379,16 @@ }, { "name": "spatie/laravel-ignition", - "version": "1.0.9", + "version": "1.0.10", "source": { "type": "git", "url": "https://github.com/spatie/laravel-ignition.git", - "reference": "d7b223300d511145eea87fdabae1663c7c0088aa" + "reference": "71df77cad94aae4db904aaef1cc2f06950daed76" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/d7b223300d511145eea87fdabae1663c7c0088aa", - "reference": "d7b223300d511145eea87fdabae1663c7c0088aa", + "url": "https://api.github.com/repos/spatie/laravel-ignition/zipball/71df77cad94aae4db904aaef1cc2f06950daed76", + "reference": "71df77cad94aae4db904aaef1cc2f06950daed76", "shasum": "" }, "require": { @@ -14462,7 +14462,7 @@ "type": "github" } ], - "time": "2022-03-11T14:19:27+00:00" + "time": "2022-03-17T11:01:36+00:00" }, { "name": "symfony/polyfill-php73", diff --git a/src/App/Console/Commands/GenerateDemoSubscriptionContentCommand.php b/src/App/Console/Commands/GenerateDemoSubscriptionContentCommand.php index 598017f8..8d00f0d6 100644 --- a/src/App/Console/Commands/GenerateDemoSubscriptionContentCommand.php +++ b/src/App/Console/Commands/GenerateDemoSubscriptionContentCommand.php @@ -96,7 +96,7 @@ class GenerateDemoSubscriptionContentCommand extends Command $subscription->usages()->create([ 'metered_feature_id' => $bandwidthFeature->id, - 'quantity' => random_int(111, 999), + 'quantity' => random_int(111, 999) / 1000, 'created_at' => now()->subDays($item), ]); @@ -109,7 +109,7 @@ class GenerateDemoSubscriptionContentCommand extends Command $subscription->usages()->create([ 'metered_feature_id' => $storageFeature->id, - 'quantity' => random_int(1111, 3999), + 'quantity' => random_int(1111, 3999) / 1000, 'created_at' => now()->subDays($item), ]); } @@ -193,8 +193,8 @@ class GenerateDemoSubscriptionContentCommand extends Command ], ])->each( function ($transaction) use ($user, $plan) { - $bandwidthUsage = random_int(1000, 12000); - $storageUsage = random_int(300, 4900); + $bandwidthUsage = random_int(1000, 12000) / 1000; + $storageUsage = random_int(300, 4900) / 1000; $memberUsage = random_int(3, 20); $user->transactions()->create([ diff --git a/src/App/Users/Actions/FormatUsageEstimatesAction.php b/src/App/Users/Actions/FormatUsageEstimatesAction.php index cb98ef51..1d2fa217 100644 --- a/src/App/Users/Actions/FormatUsageEstimatesAction.php +++ b/src/App/Users/Actions/FormatUsageEstimatesAction.php @@ -12,22 +12,16 @@ class FormatUsageEstimatesAction ->mapWithKeys(function ($estimate) use ($currency) { // Format usage $usage = match ($estimate['feature']) { - 'bandwidth', 'storage' => Metric::megabytes($estimate['usage'])->format(), + 'bandwidth', 'storage' => Metric::megabytes($estimate['usage'] * 1000)->format(), 'flatFee' => intval($estimate['usage']) . ' ' . __('Pcs.'), 'member' => intval($estimate['usage']) . ' ' . __('Mem.'), }; - // Normalize units - $amount = match ($estimate['feature']) { - 'bandwidth', 'storage' => $estimate['amount'] / 1000, - 'flatFee', 'member' => $estimate['amount'], - }; - return [ $estimate['feature'] => [ 'feature' => $estimate['feature'], - 'amount' => $amount, - 'cost' => format_currency($amount, $currency), + 'amount' => $estimate['amount'], + 'cost' => format_currency($estimate['amount'], $currency), 'usage' => $usage, ], ]; diff --git a/src/Support/Scheduler/Actions/ReportUsageAction.php b/src/Support/Scheduler/Actions/ReportUsageAction.php index 42a160ae..51d30486 100644 --- a/src/Support/Scheduler/Actions/ReportUsageAction.php +++ b/src/Support/Scheduler/Actions/ReportUsageAction.php @@ -38,8 +38,8 @@ class ReportUsageAction ->where('user_id', $subscription->user->id) ->sum('filesize'); - // We count storage size in GB, e.g. 0.15 is 150mb - $amount = $filesize / 1000000; + // We count storage size in GB, e.g. 0.150 is 150mb + $amount = $filesize / 1_000_000_000; // Record storage capacity usage $subscription->recordUsage('storage', $amount); @@ -54,7 +54,7 @@ class ReportUsageAction ->whereDate('created_at', today()->subDay()) ->first(); - $amount = (($record->download ?? 0) + ($record->upload ?? 0)) / 1000000; + $amount = (($record->download ?? 0) + ($record->upload ?? 0)) / 1_000_000_000; // Record storage capacity usage $subscription->recordUsage('bandwidth', $amount);