Implement cron to remove expired bids
This commit is contained in:
27
app/Console/Cron/Hourly.php
Normal file
27
app/Console/Cron/Hourly.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Cron;
|
||||
|
||||
use App\Console\Command;
|
||||
use App\Events\CronHourly;
|
||||
|
||||
/**
|
||||
* This just calls the CronHourly event, so all of the
|
||||
* listeners, etc can just be called to run those tasks
|
||||
* @package App\Console\Cron
|
||||
*/
|
||||
class Hourly extends Command
|
||||
{
|
||||
protected $signature = 'cron:hourly';
|
||||
protected $description = 'Run the hourly cron tasks';
|
||||
protected $schedule;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$this->redirectLoggingToStdout('cron');
|
||||
event(new CronHourly());
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use App\Console\Cron\Hourly;
|
||||
use App\Console\Cron\Monthly;
|
||||
use App\Console\Cron\Nightly;
|
||||
use App\Console\Cron\Weekly;
|
||||
@@ -34,6 +35,7 @@ class Kernel extends ConsoleKernel
|
||||
$schedule->command(Nightly::class)->dailyAt('01:00');
|
||||
$schedule->command(Weekly::class)->weeklyOn(0);
|
||||
$schedule->command(Monthly::class)->monthlyOn(1);
|
||||
$schedule->command(Hourly::class)->hourly();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
30
app/Cron/Hourly/RemoveExpiredBids.php
Normal file
30
app/Cron/Hourly/RemoveExpiredBids.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Cron\Hourly;
|
||||
|
||||
use App\Events\CronHourly;
|
||||
use App\Interfaces\Listener;
|
||||
use App\Models\Bid;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Remove expired bids
|
||||
* @package App\Listeners\Cron\Hourly
|
||||
*/
|
||||
class RemoveExpiredBids extends Listener
|
||||
{
|
||||
/**
|
||||
* Remove expired bids
|
||||
* @param CronHourly $event
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function handle(CronHourly $event): void
|
||||
{
|
||||
if(setting('bids.expire_time') === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$date = Carbon::now()->subHours(setting('bids.expire_time'));
|
||||
Bid::whereDate('created_at', '<', $date)->delete();
|
||||
}
|
||||
}
|
||||
23
app/Events/CronHourly.php
Normal file
23
app/Events/CronHourly.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* This event is dispatched when the hourly cron is run
|
||||
* @package App\Events
|
||||
*/
|
||||
class CronHourly
|
||||
{
|
||||
use Dispatchable, SerializesModels;
|
||||
|
||||
/**
|
||||
* CronNightly constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\Providers;
|
||||
|
||||
use App\Cron\Nightly\RecalculateStats;
|
||||
use App\Cron\Nightly\SetActiveFlights;
|
||||
use App\Events\CronHourly;
|
||||
use App\Events\CronMonthly;
|
||||
use App\Events\CronNightly;
|
||||
use App\Events\CronWeekly;
|
||||
@@ -33,5 +34,9 @@ class CronServiceProvider extends ServiceProvider
|
||||
CronMonthly::class => [
|
||||
\App\Cron\Monthly\ApplyExpenses::class
|
||||
],
|
||||
|
||||
CronHourly::class => [
|
||||
\App\Cron\Hourly\RemoveExpiredBids::class
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -52,7 +52,8 @@
|
||||
"nunomaduro/collision": "^2.0",
|
||||
"phpstan/phpstan": "^0.9.2",
|
||||
"weebly/phpstan-laravel": "^1.1",
|
||||
"codedungeon/phpunit-result-printer": "^0.13.0"
|
||||
"codedungeon/phpunit-result-printer": "^0.13.0",
|
||||
"barryvdh/laravel-debugbar": "^3.1"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
|
||||
173
composer.lock
generated
173
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "1c9830cc5b142394ecd3a80cd2e1dc9c",
|
||||
"content-hash": "65637d77694e68aa106afd92650fde71",
|
||||
"packages": [
|
||||
{
|
||||
"name": "akaunting/money",
|
||||
@@ -69,16 +69,16 @@
|
||||
},
|
||||
{
|
||||
"name": "anhskohbo/no-captcha",
|
||||
"version": "3.0.1",
|
||||
"version": "3.0.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/anhskohbo/no-captcha.git",
|
||||
"reference": "f6c3a006b8c74f692d232d861c3e104621f50dcc"
|
||||
"reference": "821a256c692392941ab165893bb642557f94f918"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/anhskohbo/no-captcha/zipball/f6c3a006b8c74f692d232d861c3e104621f50dcc",
|
||||
"reference": "f6c3a006b8c74f692d232d861c3e104621f50dcc",
|
||||
"url": "https://api.github.com/repos/anhskohbo/no-captcha/zipball/821a256c692392941ab165893bb642557f94f918",
|
||||
"reference": "821a256c692392941ab165893bb642557f94f918",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -124,7 +124,7 @@
|
||||
"no-captcha",
|
||||
"recaptcha"
|
||||
],
|
||||
"time": "2018-02-09T02:04:49+00:00"
|
||||
"time": "2018-08-10T11:44:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "arrilot/laravel-widgets",
|
||||
@@ -1498,16 +1498,16 @@
|
||||
},
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"version": "v5.6.33",
|
||||
"version": "v5.6.34",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/framework.git",
|
||||
"reference": "8a708b989adc320c451ee639d812af81f884666b"
|
||||
"reference": "66c9cf8119b422b71273271db1f12e20d74ad49b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/8a708b989adc320c451ee639d812af81f884666b",
|
||||
"reference": "8a708b989adc320c451ee639d812af81f884666b",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/66c9cf8119b422b71273271db1f12e20d74ad49b",
|
||||
"reference": "66c9cf8119b422b71273271db1f12e20d74ad49b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1633,7 +1633,7 @@
|
||||
"framework",
|
||||
"laravel"
|
||||
],
|
||||
"time": "2018-08-09T20:36:39+00:00"
|
||||
"time": "2018-08-21T13:44:37+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravelcollective/html",
|
||||
@@ -1772,16 +1772,16 @@
|
||||
},
|
||||
{
|
||||
"name": "league/flysystem",
|
||||
"version": "1.0.45",
|
||||
"version": "1.0.46",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/thephpleague/flysystem.git",
|
||||
"reference": "a99f94e63b512d75f851b181afcdf0ee9ebef7e6"
|
||||
"reference": "f3e0d925c18b92cf3ce84ea5cc58d62a1762a2b2"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/a99f94e63b512d75f851b181afcdf0ee9ebef7e6",
|
||||
"reference": "a99f94e63b512d75f851b181afcdf0ee9ebef7e6",
|
||||
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/f3e0d925c18b92cf3ce84ea5cc58d62a1762a2b2",
|
||||
"reference": "f3e0d925c18b92cf3ce84ea5cc58d62a1762a2b2",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1793,7 +1793,7 @@
|
||||
"require-dev": {
|
||||
"ext-fileinfo": "*",
|
||||
"phpspec/phpspec": "^3.4",
|
||||
"phpunit/phpunit": "^5.7"
|
||||
"phpunit/phpunit": "^5.7.10"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-fileinfo": "Required for MimeType",
|
||||
@@ -1852,7 +1852,7 @@
|
||||
"sftp",
|
||||
"storage"
|
||||
],
|
||||
"time": "2018-05-07T08:44:23+00:00"
|
||||
"time": "2018-08-22T07:45:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "league/geotools",
|
||||
@@ -5040,6 +5040,74 @@
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "barryvdh/laravel-debugbar",
|
||||
"version": "v3.1.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/barryvdh/laravel-debugbar.git",
|
||||
"reference": "d3cdca2ad6cc6e67735b4a63e7551c690a497f5f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/d3cdca2ad6cc6e67735b4a63e7551c690a497f5f",
|
||||
"reference": "d3cdca2ad6cc6e67735b4a63e7551c690a497f5f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/routing": "5.5.x|5.6.x",
|
||||
"illuminate/session": "5.5.x|5.6.x",
|
||||
"illuminate/support": "5.5.x|5.6.x",
|
||||
"maximebf/debugbar": "~1.15.0",
|
||||
"php": ">=7.0",
|
||||
"symfony/debug": "^3|^4",
|
||||
"symfony/finder": "^3|^4"
|
||||
},
|
||||
"require-dev": {
|
||||
"illuminate/framework": "5.5.x"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.2-dev"
|
||||
},
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Barryvdh\\Debugbar\\ServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"Debugbar": "Barryvdh\\Debugbar\\Facade"
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Barryvdh\\Debugbar\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/helpers.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Barry vd. Heuvel",
|
||||
"email": "barryvdh@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "PHP Debugbar integration for Laravel",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"debugbar",
|
||||
"laravel",
|
||||
"profiler",
|
||||
"webprofiler"
|
||||
],
|
||||
"time": "2018-05-03T18:27:04+00:00"
|
||||
},
|
||||
{
|
||||
"name": "barryvdh/laravel-ide-helper",
|
||||
"version": "v2.4.3",
|
||||
@@ -5663,6 +5731,67 @@
|
||||
],
|
||||
"time": "2018-06-13T13:22:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "maximebf/debugbar",
|
||||
"version": "v1.15.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/maximebf/php-debugbar.git",
|
||||
"reference": "30e7d60937ee5f1320975ca9bc7bcdd44d500f07"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/30e7d60937ee5f1320975ca9bc7bcdd44d500f07",
|
||||
"reference": "30e7d60937ee5f1320975ca9bc7bcdd44d500f07",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
"psr/log": "^1.0",
|
||||
"symfony/var-dumper": "^2.6|^3.0|^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.0|^5.0"
|
||||
},
|
||||
"suggest": {
|
||||
"kriswallsmith/assetic": "The best way to manage assets",
|
||||
"monolog/monolog": "Log using Monolog",
|
||||
"predis/predis": "Redis storage"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.14-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"DebugBar\\": "src/DebugBar/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Maxime Bouroumeau-Fuseau",
|
||||
"email": "maxime.bouroumeau@gmail.com",
|
||||
"homepage": "http://maximebf.com"
|
||||
},
|
||||
{
|
||||
"name": "Barry vd. Heuvel",
|
||||
"email": "barryvdh@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Debug bar in the browser for php application",
|
||||
"homepage": "https://github.com/maximebf/php-debugbar",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"debugbar"
|
||||
],
|
||||
"time": "2017-12-15T11:13:46+00:00"
|
||||
},
|
||||
{
|
||||
"name": "mockery/mockery",
|
||||
"version": "0.9.9",
|
||||
@@ -7041,16 +7170,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "7.3.1",
|
||||
"version": "7.3.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "f9b14c17860eccb440a0352a117a81eb754cff5a"
|
||||
"reference": "34705f81bddc3f505b9599a2ef96e2b4315ba9b8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f9b14c17860eccb440a0352a117a81eb754cff5a",
|
||||
"reference": "f9b14c17860eccb440a0352a117a81eb754cff5a",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/34705f81bddc3f505b9599a2ef96e2b4315ba9b8",
|
||||
"reference": "34705f81bddc3f505b9599a2ef96e2b4315ba9b8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -7121,7 +7250,7 @@
|
||||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2018-08-07T06:44:28+00:00"
|
||||
"time": "2018-08-22T06:39:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/code-unit-reverse-lookup",
|
||||
|
||||
2
storage/debugbar/.gitignore
vendored
Normal file
2
storage/debugbar/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
Reference in New Issue
Block a user