Improve efficiency of lightlogs

This commit is contained in:
David Bomba 2022-09-08 18:57:32 +10:00
parent 99045110ed
commit efbca7d753
4 changed files with 91 additions and 166 deletions

View File

@ -68,7 +68,7 @@ class QueryLogging
$ip = request()->ip();
}
LightLogs::create(new DbQuery($request->method(), urldecode($request->url()), $count, $time, $ip))
LightLogs::create(new DbQuery($request->method(), substr(urldecode($request->url()),0,180), $count, $time, $ip))
->queue();
}

View File

@ -11,6 +11,7 @@
namespace App\Jobs\Ninja;
use App\DataMapper\Analytics\EmailCount;
use App\Libraries\MultiDB;
use App\Models\Account;
use App\Utils\Ninja;
@ -20,6 +21,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Cache;
use Turbo124\Beacon\Facades\LightLogs;
class AdjustEmailQuota implements ShouldQueue
{
@ -58,8 +60,15 @@ class AdjustEmailQuota implements ShouldQueue
{
Account::query()->cursor()->each(function ($account) {
nlog("resetting email quota for {$account->key}");
$email_count = Cache::get($account->key);
if($email_count > 0)
LightLogs::create(new EmailCount($email_count, $account->key))->batch();
Cache::forget($account->key);
Cache::forget("throttle_notified:{$account->key}");
});
}
}

View File

@ -88,7 +88,7 @@
"symfony/mailgun-mailer": "^6.1",
"symfony/postmark-mailer": "^6.1",
"tijsverkoyen/css-to-inline-styles": "^2.2",
"turbo124/beacon": "^1.2",
"turbo124/beacon": "^1.3",
"twilio/sdk": "^6.40",
"webpatser/laravel-countries": "dev-master#75992ad",
"wepay/php-sdk": "^0.3"

244
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "68269627da68ba8ad674df71001d16ea",
"content-hash": "8d9b065d1cf3f4fd42565e77e63c53fc",
"packages": [
{
"name": "afosto/yaac",
@ -378,16 +378,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.235.1",
"version": "3.235.3",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "2025db05c7dd22ae414857dadd49207f64c2fc74"
"reference": "d14bf468240f5bd8a0754b8a8248ff219ebada02"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/2025db05c7dd22ae414857dadd49207f64c2fc74",
"reference": "2025db05c7dd22ae414857dadd49207f64c2fc74",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/d14bf468240f5bd8a0754b8a8248ff219ebada02",
"reference": "d14bf468240f5bd8a0754b8a8248ff219ebada02",
"shasum": ""
},
"require": {
@ -464,9 +464,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.235.1"
"source": "https://github.com/aws/aws-sdk-php/tree/3.235.3"
},
"time": "2022-09-02T18:18:19+00:00"
"time": "2022-09-07T18:17:39+00:00"
},
{
"name": "bacon/bacon-qr-code",
@ -1165,16 +1165,16 @@
},
{
"name": "doctrine/dbal",
"version": "3.4.3",
"version": "3.4.4",
"source": {
"type": "git",
"url": "https://github.com/doctrine/dbal.git",
"reference": "a24b89d663d8f261199bc0a91c48016042ebda85"
"reference": "4cbbe6e4b9ef6c69d5f4c968c637476f47bb54f5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/a24b89d663d8f261199bc0a91c48016042ebda85",
"reference": "a24b89d663d8f261199bc0a91c48016042ebda85",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/4cbbe6e4b9ef6c69d5f4c968c637476f47bb54f5",
"reference": "4cbbe6e4b9ef6c69d5f4c968c637476f47bb54f5",
"shasum": ""
},
"require": {
@ -1189,14 +1189,14 @@
"require-dev": {
"doctrine/coding-standard": "10.0.0",
"jetbrains/phpstorm-stubs": "2022.2",
"phpstan/phpstan": "1.8.2",
"phpstan/phpstan": "1.8.3",
"phpstan/phpstan-strict-rules": "^1.3",
"phpunit/phpunit": "9.5.21",
"phpunit/phpunit": "9.5.24",
"psalm/plugin-phpunit": "0.17.0",
"squizlabs/php_codesniffer": "3.7.1",
"symfony/cache": "^5.4|^6.0",
"symfony/console": "^4.4|^5.4|^6.0",
"vimeo/psalm": "4.24.0"
"vimeo/psalm": "4.27.0"
},
"suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files."
@ -1256,7 +1256,7 @@
],
"support": {
"issues": "https://github.com/doctrine/dbal/issues",
"source": "https://github.com/doctrine/dbal/tree/3.4.3"
"source": "https://github.com/doctrine/dbal/tree/3.4.4"
},
"funding": [
{
@ -1272,7 +1272,7 @@
"type": "tidelift"
}
],
"time": "2022-08-28T17:26:36+00:00"
"time": "2022-09-01T21:26:42+00:00"
},
{
"name": "doctrine/deprecations",
@ -1410,28 +1410,28 @@
},
{
"name": "doctrine/inflector",
"version": "2.0.4",
"version": "2.0.5",
"source": {
"type": "git",
"url": "https://github.com/doctrine/inflector.git",
"reference": "8b7ff3e4b7de6b2c84da85637b59fd2880ecaa89"
"reference": "ade2b3bbfb776f27f0558e26eed43b5d9fe1b392"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/inflector/zipball/8b7ff3e4b7de6b2c84da85637b59fd2880ecaa89",
"reference": "8b7ff3e4b7de6b2c84da85637b59fd2880ecaa89",
"url": "https://api.github.com/repos/doctrine/inflector/zipball/ade2b3bbfb776f27f0558e26eed43b5d9fe1b392",
"reference": "ade2b3bbfb776f27f0558e26eed43b5d9fe1b392",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"require-dev": {
"doctrine/coding-standard": "^8.2",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpstan/phpstan-strict-rules": "^0.12",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"vimeo/psalm": "^4.10"
"doctrine/coding-standard": "^9",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-strict-rules": "^1.3",
"phpunit/phpunit": "^8.5 || ^9.5",
"vimeo/psalm": "^4.25"
},
"type": "library",
"autoload": {
@ -1481,7 +1481,7 @@
],
"support": {
"issues": "https://github.com/doctrine/inflector/issues",
"source": "https://github.com/doctrine/inflector/tree/2.0.4"
"source": "https://github.com/doctrine/inflector/tree/2.0.5"
},
"funding": [
{
@ -1497,7 +1497,7 @@
"type": "tidelift"
}
],
"time": "2021-10-22T20:16:43+00:00"
"time": "2022-09-07T09:01:28+00:00"
},
{
"name": "doctrine/lexer",
@ -3481,16 +3481,16 @@
},
{
"name": "laravel/framework",
"version": "v9.27.0",
"version": "v9.28.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "27572f45120fd3977d92651a71d8c711a9aaa790"
"reference": "396a89e1f3654123d1c7f56306051212e5c75bc0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/27572f45120fd3977d92651a71d8c711a9aaa790",
"reference": "27572f45120fd3977d92651a71d8c711a9aaa790",
"url": "https://api.github.com/repos/laravel/framework/zipball/396a89e1f3654123d1c7f56306051212e5c75bc0",
"reference": "396a89e1f3654123d1c7f56306051212e5c75bc0",
"shasum": ""
},
"require": {
@ -3657,7 +3657,7 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2022-08-30T13:34:43+00:00"
"time": "2022-09-06T14:57:01+00:00"
},
{
"name": "laravel/serializable-closure",
@ -6812,16 +6812,16 @@
},
{
"name": "phpseclib/phpseclib",
"version": "3.0.15",
"version": "3.0.16",
"source": {
"type": "git",
"url": "https://github.com/phpseclib/phpseclib.git",
"reference": "c96e250238e88bf1040e9f7715efab1d6bc7f622"
"reference": "7181378909ed8890be4db53d289faac5b77f8b05"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/c96e250238e88bf1040e9f7715efab1d6bc7f622",
"reference": "c96e250238e88bf1040e9f7715efab1d6bc7f622",
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/7181378909ed8890be4db53d289faac5b77f8b05",
"reference": "7181378909ed8890be4db53d289faac5b77f8b05",
"shasum": ""
},
"require": {
@ -6902,7 +6902,7 @@
],
"support": {
"issues": "https://github.com/phpseclib/phpseclib/issues",
"source": "https://github.com/phpseclib/phpseclib/tree/3.0.15"
"source": "https://github.com/phpseclib/phpseclib/tree/3.0.16"
},
"funding": [
{
@ -6918,7 +6918,7 @@
"type": "tidelift"
}
],
"time": "2022-09-02T17:05:08+00:00"
"time": "2022-09-05T18:03:08+00:00"
},
{
"name": "pragmarx/google2fa",
@ -8073,16 +8073,16 @@
},
{
"name": "sentry/sentry",
"version": "3.7.0",
"version": "3.8.0",
"source": {
"type": "git",
"url": "https://github.com/getsentry/sentry-php.git",
"reference": "877bca3f0f0ac0fc8ec0a218c6070cccea266795"
"reference": "dc599ef4ac5459fef95cc0414d26ac47e300e1dc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/877bca3f0f0ac0fc8ec0a218c6070cccea266795",
"reference": "877bca3f0f0ac0fc8ec0a218c6070cccea266795",
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/dc599ef4ac5459fef95cc0414d26ac47e300e1dc",
"reference": "dc599ef4ac5459fef95cc0414d26ac47e300e1dc",
"shasum": ""
},
"require": {
@ -8101,8 +8101,7 @@
"psr/http-message-implementation": "^1.0",
"psr/log": "^1.0|^2.0|^3.0",
"symfony/options-resolver": "^3.4.43|^4.4.30|^5.0.11|^6.0",
"symfony/polyfill-php80": "^1.17",
"symfony/polyfill-uuid": "^1.13.1"
"symfony/polyfill-php80": "^1.17"
},
"conflict": {
"php-http/client-common": "1.8.0",
@ -8128,7 +8127,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.7.x-dev"
"dev-master": "3.8.x-dev"
}
},
"autoload": {
@ -8162,7 +8161,7 @@
],
"support": {
"issues": "https://github.com/getsentry/sentry-php/issues",
"source": "https://github.com/getsentry/sentry-php/tree/3.7.0"
"source": "https://github.com/getsentry/sentry-php/tree/3.8.0"
},
"funding": [
{
@ -8174,7 +8173,7 @@
"type": "custom"
}
],
"time": "2022-07-18T07:55:36+00:00"
"time": "2022-09-05T14:25:47+00:00"
},
{
"name": "sentry/sentry-laravel",
@ -10919,88 +10918,6 @@
],
"time": "2022-05-24T11:49:31+00:00"
},
{
"name": "symfony/polyfill-uuid",
"version": "v1.26.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-uuid.git",
"reference": "a41886c1c81dc075a09c71fe6db5b9d68c79de23"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-uuid/zipball/a41886c1c81dc075a09c71fe6db5b9d68c79de23",
"reference": "a41886c1c81dc075a09c71fe6db5b9d68c79de23",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"provide": {
"ext-uuid": "*"
},
"suggest": {
"ext-uuid": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.26-dev"
},
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Uuid\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Grégoire Pineau",
"email": "lyrixx@lyrixx.info"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for uuid functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"uuid"
],
"support": {
"source": "https://github.com/symfony/polyfill-uuid/tree/v1.26.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2022-05-24T11:49:31+00:00"
},
{
"name": "symfony/postmark-mailer",
"version": "v6.1.0",
@ -11299,16 +11216,16 @@
},
{
"name": "symfony/psr-http-message-bridge",
"version": "v2.1.2",
"version": "v2.1.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/psr-http-message-bridge.git",
"reference": "22b37c8a3f6b5d94e9cdbd88e1270d96e2f97b34"
"reference": "d444f85dddf65c7e57c58d8e5b3a4dbb593b1840"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/22b37c8a3f6b5d94e9cdbd88e1270d96e2f97b34",
"reference": "22b37c8a3f6b5d94e9cdbd88e1270d96e2f97b34",
"url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/d444f85dddf65c7e57c58d8e5b3a4dbb593b1840",
"reference": "d444f85dddf65c7e57c58d8e5b3a4dbb593b1840",
"shasum": ""
},
"require": {
@ -11367,7 +11284,7 @@
],
"support": {
"issues": "https://github.com/symfony/psr-http-message-bridge/issues",
"source": "https://github.com/symfony/psr-http-message-bridge/tree/v2.1.2"
"source": "https://github.com/symfony/psr-http-message-bridge/tree/v2.1.3"
},
"funding": [
{
@ -11383,7 +11300,7 @@
"type": "tidelift"
}
],
"time": "2021-11-05T13:13:39+00:00"
"time": "2022-09-05T10:34:54+00:00"
},
{
"name": "symfony/routing",
@ -12071,26 +11988,25 @@
},
{
"name": "turbo124/beacon",
"version": "v1.2.0",
"version": "v1.3.2",
"source": {
"type": "git",
"url": "https://github.com/turbo124/beacon.git",
"reference": "3e3bd337f91666ae793b6682ef40fd228aa6f185"
"reference": "e46e6122e28c2a7628ad40975bfd11a3ab883575"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/turbo124/beacon/zipball/3e3bd337f91666ae793b6682ef40fd228aa6f185",
"reference": "3e3bd337f91666ae793b6682ef40fd228aa6f185",
"url": "https://api.github.com/repos/turbo124/beacon/zipball/e46e6122e28c2a7628ad40975bfd11a3ab883575",
"reference": "e46e6122e28c2a7628ad40975bfd11a3ab883575",
"shasum": ""
},
"require": {
"guzzlehttp/guzzle": "^7",
"illuminate/support": "^6.0|^7.0|^8.0|^9.0",
"php": "^7.3|^7.4|^8"
"illuminate/support": "^9.0",
"php": "^8"
},
"require-dev": {
"orchestra/testbench": "^4.0",
"phpunit/phpunit": "^8.0"
"phpunit/phpunit": "^9.0"
},
"type": "library",
"extra": {
@ -12128,22 +12044,22 @@
"turbo124"
],
"support": {
"source": "https://github.com/turbo124/beacon/tree/v1.2.0"
"source": "https://github.com/turbo124/beacon/tree/v1.3.2"
},
"time": "2022-06-22T11:22:46+00:00"
"time": "2022-09-08T08:08:59+00:00"
},
{
"name": "twilio/sdk",
"version": "6.41.0",
"version": "6.42.0",
"source": {
"type": "git",
"url": "git@github.com:twilio/twilio-php.git",
"reference": "3e6b81216052aac086efd6334a0fc358c38c2e20"
"reference": "fff5abe683e7d51912ee782012684daa0959e45b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/twilio/twilio-php/zipball/3e6b81216052aac086efd6334a0fc358c38c2e20",
"reference": "3e6b81216052aac086efd6334a0fc358c38c2e20",
"url": "https://api.github.com/repos/twilio/twilio-php/zipball/fff5abe683e7d51912ee782012684daa0959e45b",
"reference": "fff5abe683e7d51912ee782012684daa0959e45b",
"shasum": ""
},
"require": {
@ -12179,7 +12095,7 @@
"sms",
"twilio"
],
"time": "2022-08-24T20:39:42+00:00"
"time": "2022-09-07T19:17:29+00:00"
},
{
"name": "vlucas/phpdotenv",
@ -13764,16 +13680,16 @@
},
{
"name": "maximebf/debugbar",
"version": "v1.18.0",
"version": "v1.18.1",
"source": {
"type": "git",
"url": "https://github.com/maximebf/php-debugbar.git",
"reference": "0d44b75f3b5d6d41ae83b79c7a4bceae7fbc78b6"
"reference": "ba0af68dd4316834701ecb30a00ce9604ced3ee9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/0d44b75f3b5d6d41ae83b79c7a4bceae7fbc78b6",
"reference": "0d44b75f3b5d6d41ae83b79c7a4bceae7fbc78b6",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/ba0af68dd4316834701ecb30a00ce9604ced3ee9",
"reference": "ba0af68dd4316834701ecb30a00ce9604ced3ee9",
"shasum": ""
},
"require": {
@ -13793,7 +13709,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.17-dev"
"dev-master": "1.18-dev"
}
},
"autoload": {
@ -13824,22 +13740,22 @@
],
"support": {
"issues": "https://github.com/maximebf/php-debugbar/issues",
"source": "https://github.com/maximebf/php-debugbar/tree/v1.18.0"
"source": "https://github.com/maximebf/php-debugbar/tree/v1.18.1"
},
"time": "2021-12-27T18:49:48+00:00"
"time": "2022-03-31T14:55:54+00:00"
},
{
"name": "mockery/mockery",
"version": "1.5.0",
"version": "1.5.1",
"source": {
"type": "git",
"url": "https://github.com/mockery/mockery.git",
"reference": "c10a5f6e06fc2470ab1822fa13fa2a7380f8fbac"
"reference": "e92dcc83d5a51851baf5f5591d32cb2b16e3684e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mockery/mockery/zipball/c10a5f6e06fc2470ab1822fa13fa2a7380f8fbac",
"reference": "c10a5f6e06fc2470ab1822fa13fa2a7380f8fbac",
"url": "https://api.github.com/repos/mockery/mockery/zipball/e92dcc83d5a51851baf5f5591d32cb2b16e3684e",
"reference": "e92dcc83d5a51851baf5f5591d32cb2b16e3684e",
"shasum": ""
},
"require": {
@ -13896,9 +13812,9 @@
],
"support": {
"issues": "https://github.com/mockery/mockery/issues",
"source": "https://github.com/mockery/mockery/tree/1.5.0"
"source": "https://github.com/mockery/mockery/tree/1.5.1"
},
"time": "2022-01-20T13:18:17+00:00"
"time": "2022-09-07T15:32:08+00:00"
},
{
"name": "myclabs/deep-copy",