From 8406f129808e0179f0fd27c7e77c9dcf1e78a994 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 20 Dec 2023 16:55:33 +1100 Subject: [PATCH] Fixes for update client webhooks --- app/Console/Commands/TypeCheck.php | 4 +- app/Console/Kernel.php | 2 +- app/Jobs/Ninja/CompanySizeCheck.php | 29 +++++++-- composer.lock | 98 ++++++++++++++--------------- 4 files changed, 75 insertions(+), 58 deletions(-) diff --git a/app/Console/Commands/TypeCheck.php b/app/Console/Commands/TypeCheck.php index 7a57791eb4..5e8aff3754 100644 --- a/app/Console/Commands/TypeCheck.php +++ b/app/Console/Commands/TypeCheck.php @@ -100,7 +100,7 @@ class TypeCheck extends Command $entity_settings = $this->checkSettingType($client->settings); $entity_settings->md5 = md5(time()); $client->settings = $entity_settings; - $client->save(); + $client->saveQuietly(); } private function checkCompany($company) @@ -119,7 +119,7 @@ class TypeCheck extends Command $entity_settings = $this->checkSettingType($client->settings); $entity_settings->md5 = md5(time()); $client->settings = $entity_settings; - $client->save(); + $client->saveQuietly(); }); Company::query()->cursor()->each(function ($company) { diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index f67dc4af68..9d7067b6bd 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -99,7 +99,7 @@ class Kernel extends ConsoleKernel if (Ninja::isSelfHost()) { $schedule->call(function () { - Account::whereNotNull('id')->update(['is_scheduler_running' => true]); + Account::query()->whereNotNull('id')->update(['is_scheduler_running' => true]); })->everyFiveMinutes(); } diff --git a/app/Jobs/Ninja/CompanySizeCheck.php b/app/Jobs/Ninja/CompanySizeCheck.php index 2eeb238a2e..b1c0ca4449 100644 --- a/app/Jobs/Ninja/CompanySizeCheck.php +++ b/app/Jobs/Ninja/CompanySizeCheck.php @@ -53,11 +53,19 @@ class CompanySizeCheck implements ShouldQueue nlog("updating all client credit balances"); - Client::where('updated_at', '>', now()->subDay()) + Client::query() + ->where('updated_at', '>', now()->subDay()) ->cursor() ->each(function ($client) { - $client->credit_balance = $client->service()->getCreditBalance(); - $client->save(); + + $old_credit_balance = $client->credit_balance; + $new_credit_balance = $client->service()->getCreditBalance(); + + if(floatval($old_credit_balance) !== floatval($new_credit_balance)){ + $client->credit_balance = $client->service()->getCreditBalance(); + $client->saveQuietly(); + } + }); /* Ensures lower permissioned users return the correct dataset and refresh responses */ @@ -87,11 +95,20 @@ class CompanySizeCheck implements ShouldQueue nlog("updating all client credit balances"); - Client::where('updated_at', '>', now()->subDay()) + Client::query()->where('updated_at', '>', now()->subDay()) ->cursor() ->each(function ($client) { - $client->credit_balance = $client->service()->getCreditBalance(); - $client->save(); + + + $old_credit_balance = $client->credit_balance; + $new_credit_balance = $client->service()->getCreditBalance(); + + if(floatval($old_credit_balance) !== floatval($new_credit_balance)) { + $client->credit_balance = $client->service()->getCreditBalance(); + $client->saveQuietly(); + } + + }); Account::where('plan', 'enterprise') diff --git a/composer.lock b/composer.lock index 8939b22cea..7d2e2f9585 100644 --- a/composer.lock +++ b/composer.lock @@ -485,16 +485,16 @@ }, { "name": "aws/aws-sdk-php", - "version": "3.294.1", + "version": "3.294.3", "source": { "type": "git", "url": "https://github.com/aws/aws-sdk-php.git", - "reference": "63c720229a9c9cdedff6bac98d6e72be8cc241f1" + "reference": "05761093c61ca7a02c1b5ae9be279bf69360e060" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/63c720229a9c9cdedff6bac98d6e72be8cc241f1", - "reference": "63c720229a9c9cdedff6bac98d6e72be8cc241f1", + "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/05761093c61ca7a02c1b5ae9be279bf69360e060", + "reference": "05761093c61ca7a02c1b5ae9be279bf69360e060", "shasum": "" }, "require": { @@ -574,9 +574,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.294.1" + "source": "https://github.com/aws/aws-sdk-php/tree/3.294.3" }, - "time": "2023-12-15T19:25:52+00:00" + "time": "2023-12-19T19:07:14+00:00" }, { "name": "bacon/bacon-qr-code", @@ -1052,16 +1052,16 @@ }, { "name": "composer/ca-bundle", - "version": "1.3.7", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "76e46335014860eec1aa5a724799a00a2e47cc85" + "reference": "b66d11b7479109ab547f9405b97205640b17d385" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/76e46335014860eec1aa5a724799a00a2e47cc85", - "reference": "76e46335014860eec1aa5a724799a00a2e47cc85", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/b66d11b7479109ab547f9405b97205640b17d385", + "reference": "b66d11b7479109ab547f9405b97205640b17d385", "shasum": "" }, "require": { @@ -1073,7 +1073,7 @@ "phpstan/phpstan": "^0.12.55", "psr/log": "^1.0", "symfony/phpunit-bridge": "^4.2 || ^5", - "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0 || ^6.0" + "symfony/process": "^2.5 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0" }, "type": "library", "extra": { @@ -1108,7 +1108,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/ca-bundle/issues", - "source": "https://github.com/composer/ca-bundle/tree/1.3.7" + "source": "https://github.com/composer/ca-bundle/tree/1.4.0" }, "funding": [ { @@ -1124,7 +1124,7 @@ "type": "tidelift" } ], - "time": "2023-08-30T09:31:38+00:00" + "time": "2023-12-18T12:05:55+00:00" }, { "name": "dasprid/enum", @@ -2039,16 +2039,16 @@ }, { "name": "endroid/qr-code", - "version": "5.0.2", + "version": "5.0.3", "source": { "type": "git", "url": "https://github.com/endroid/qr-code.git", - "reference": "e58d34fa0b86a62696144baba9d80ee98845f957" + "reference": "c4c864a401da6afa763dfef887b131bfcc78b535" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/endroid/qr-code/zipball/e58d34fa0b86a62696144baba9d80ee98845f957", - "reference": "e58d34fa0b86a62696144baba9d80ee98845f957", + "url": "https://api.github.com/repos/endroid/qr-code/zipball/c4c864a401da6afa763dfef887b131bfcc78b535", + "reference": "c4c864a401da6afa763dfef887b131bfcc78b535", "shasum": "" }, "require": { @@ -2059,7 +2059,7 @@ "khanamiryan/qrcode-detector-decoder": "^1.0.6" }, "require-dev": { - "endroid/quality": "dev-master", + "endroid/quality": "dev-main", "ext-gd": "*", "khanamiryan/qrcode-detector-decoder": "^1.0.4||^2.0.2", "setasign/fpdf": "^1.8.2" @@ -2073,7 +2073,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.x-dev" + "dev-main": "5.x-dev" } }, "autoload": { @@ -2102,7 +2102,7 @@ ], "support": { "issues": "https://github.com/endroid/qr-code/issues", - "source": "https://github.com/endroid/qr-code/tree/5.0.2" + "source": "https://github.com/endroid/qr-code/tree/5.0.3" }, "funding": [ { @@ -2110,7 +2110,7 @@ "type": "github" } ], - "time": "2023-10-04T22:55:54+00:00" + "time": "2023-12-19T23:41:52+00:00" }, { "name": "eway/eway-rapid-php", @@ -2617,16 +2617,16 @@ }, { "name": "google/apiclient-services", - "version": "v0.327.0", + "version": "v0.328.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-api-php-client-services.git", - "reference": "51a11d4ff70dd9f60334525e71bf4cf592e6d282" + "reference": "211ba786d30a4ab21e012d2b7dbefc49b4fc6a3d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/51a11d4ff70dd9f60334525e71bf4cf592e6d282", - "reference": "51a11d4ff70dd9f60334525e71bf4cf592e6d282", + "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/211ba786d30a4ab21e012d2b7dbefc49b4fc6a3d", + "reference": "211ba786d30a4ab21e012d2b7dbefc49b4fc6a3d", "shasum": "" }, "require": { @@ -2655,9 +2655,9 @@ ], "support": { "issues": "https://github.com/googleapis/google-api-php-client-services/issues", - "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.327.0" + "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.328.0" }, - "time": "2023-12-11T00:52:16+00:00" + "time": "2023-12-18T01:00:18+00:00" }, { "name": "google/auth", @@ -4366,16 +4366,16 @@ }, { "name": "laravel/framework", - "version": "v10.37.3", + "version": "v10.38.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "996375dd61f8c6e4ac262b57ed485655d71fcbdc" + "reference": "531732a17e4d0fa4fc4fb987a72abbdb93537d3a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/996375dd61f8c6e4ac262b57ed485655d71fcbdc", - "reference": "996375dd61f8c6e4ac262b57ed485655d71fcbdc", + "url": "https://api.github.com/repos/laravel/framework/zipball/531732a17e4d0fa4fc4fb987a72abbdb93537d3a", + "reference": "531732a17e4d0fa4fc4fb987a72abbdb93537d3a", "shasum": "" }, "require": { @@ -4564,7 +4564,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2023-12-13T20:10:58+00:00" + "time": "2023-12-19T14:59:00+00:00" }, { "name": "laravel/prompts", @@ -4885,16 +4885,16 @@ }, { "name": "laravel/ui", - "version": "v4.2.3", + "version": "v4.3.0", "source": { "type": "git", "url": "https://github.com/laravel/ui.git", - "reference": "eb532ea096ca1c0298c87c19233daf011fda743a" + "reference": "d166e09cdcb2e23836f694774cba77a32edb6007" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/ui/zipball/eb532ea096ca1c0298c87c19233daf011fda743a", - "reference": "eb532ea096ca1c0298c87c19233daf011fda743a", + "url": "https://api.github.com/repos/laravel/ui/zipball/d166e09cdcb2e23836f694774cba77a32edb6007", + "reference": "d166e09cdcb2e23836f694774cba77a32edb6007", "shasum": "" }, "require": { @@ -4941,9 +4941,9 @@ "ui" ], "support": { - "source": "https://github.com/laravel/ui/tree/v4.2.3" + "source": "https://github.com/laravel/ui/tree/v4.3.0" }, - "time": "2023-11-23T14:44:22+00:00" + "time": "2023-12-19T14:46:09+00:00" }, { "name": "lcobucci/clock", @@ -6156,16 +6156,16 @@ }, { "name": "mollie/mollie-api-php", - "version": "v2.63.0", + "version": "v2.64.0", "source": { "type": "git", "url": "https://github.com/mollie/mollie-api-php.git", - "reference": "642f1b87624bd1535cd198134113e14bc01ba245" + "reference": "b54e0b05b98e15233d89724933c42c249d4b13d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mollie/mollie-api-php/zipball/642f1b87624bd1535cd198134113e14bc01ba245", - "reference": "642f1b87624bd1535cd198134113e14bc01ba245", + "url": "https://api.github.com/repos/mollie/mollie-api-php/zipball/b54e0b05b98e15233d89724933c42c249d4b13d4", + "reference": "b54e0b05b98e15233d89724933c42c249d4b13d4", "shasum": "" }, "require": { @@ -6242,9 +6242,9 @@ ], "support": { "issues": "https://github.com/mollie/mollie-api-php/issues", - "source": "https://github.com/mollie/mollie-api-php/tree/v2.63.0" + "source": "https://github.com/mollie/mollie-api-php/tree/v2.64.0" }, - "time": "2023-11-06T09:20:50+00:00" + "time": "2023-12-19T16:06:39+00:00" }, { "name": "moneyphp/money", @@ -9434,16 +9434,16 @@ }, { "name": "razorpay/razorpay", - "version": "2.8.7", + "version": "2.9.0", "source": { "type": "git", "url": "https://github.com/razorpay/razorpay-php.git", - "reference": "2180c8c3c39678623f5cb8f639c39a706de14c44" + "reference": "a3d7c2bcb416091edd6a76eb5a7600eaf00ac837" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/razorpay/razorpay-php/zipball/2180c8c3c39678623f5cb8f639c39a706de14c44", - "reference": "2180c8c3c39678623f5cb8f639c39a706de14c44", + "url": "https://api.github.com/repos/razorpay/razorpay-php/zipball/a3d7c2bcb416091edd6a76eb5a7600eaf00ac837", + "reference": "a3d7c2bcb416091edd6a76eb5a7600eaf00ac837", "shasum": "" }, "require": { @@ -9495,7 +9495,7 @@ "issues": "https://github.com/Razorpay/razorpay-php/issues", "source": "https://github.com/Razorpay/razorpay-php" }, - "time": "2023-09-11T08:31:26+00:00" + "time": "2023-12-18T04:19:46+00:00" }, { "name": "rmccue/requests",