cleaning stale data weekly
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Console\Commands;
|
|||||||
|
|
||||||
//Internal Library
|
//Internal Library
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
//Library
|
//Library
|
||||||
use Commands\Library\CommandHelper;
|
use Commands\Library\CommandHelper;
|
||||||
@@ -13,6 +14,14 @@ use App\Models\Lookups\AllianceLookup;
|
|||||||
use App\Models\Lookups\CharacterLookup;
|
use App\Models\Lookups\CharacterLookup;
|
||||||
use App\Models\Lookups\CorporationLookup;
|
use App\Models\Lookups\CorporationLookup;
|
||||||
use App\Models\Lookups\ItemLookup;
|
use App\Models\Lookups\ItemLookup;
|
||||||
|
use App\Models\Finances\AllianceMarketJournal;
|
||||||
|
use App\Models\Finances\JumpBridgeJournal;
|
||||||
|
use App\Models\Finances\OfficeFeesJournal;
|
||||||
|
use App\Models\Finances\PISaleJournal;
|
||||||
|
use App\Models\Finances\PlanetProductionTaxJournal;
|
||||||
|
use App\Models\Finances\ReprocessingTaxJournal;
|
||||||
|
use App\Models\Finances\SovBillJournal;
|
||||||
|
use App\Models\Finances\StructureIndustryTaxJournal;
|
||||||
|
|
||||||
class CleanStaleDataCommand extends Command
|
class CleanStaleDataCommand extends Command
|
||||||
{
|
{
|
||||||
@@ -61,5 +70,108 @@ class CleanStaleDataCommand extends Command
|
|||||||
|
|
||||||
//Empty the alliance lookup table
|
//Empty the alliance lookup table
|
||||||
AllianceLookup::truncate();
|
AllianceLookup::truncate();
|
||||||
|
|
||||||
|
//Setup today's carbon date
|
||||||
|
$today = Carbon::now();
|
||||||
|
$ago = $today->subMonths(6);
|
||||||
|
|
||||||
|
//Clean old data from the Alliance Market Tax Journal
|
||||||
|
$markets = AllianceMarketJournal::all();
|
||||||
|
foreach($markets as $market) {
|
||||||
|
$date = new Carbon($market->created_at);
|
||||||
|
if($date->lessThan($ago)) {
|
||||||
|
AllianceMarketJournal::where([
|
||||||
|
'id' => $market->id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clean old data from Jump Bridge Journal
|
||||||
|
$jumps = JumpBridgeJournal::all();
|
||||||
|
foreach($jumps as $jump) {
|
||||||
|
$date = new Carbon($jump->created_at);
|
||||||
|
if($date->lessThan($ago)) {
|
||||||
|
JumpBridgeJournal::where([
|
||||||
|
'id' => $jump->id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clean old data from office fees journal
|
||||||
|
$offices = OfficeFeesJournal::all();
|
||||||
|
foreach($offices as $office) {
|
||||||
|
$date = new Carbon($office->created_at);
|
||||||
|
if($date->lessThan($ago)) {
|
||||||
|
OfficeFeesJournal::where([
|
||||||
|
'id' => $office->id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clean old data from pi sale journal
|
||||||
|
$pisales = PISaleJournal::all();
|
||||||
|
foreach($pisales as $sale) {
|
||||||
|
$date = new Carbon($sale->created_at);
|
||||||
|
if($date->lessThan($ago)) {
|
||||||
|
PISaleJournal::where([
|
||||||
|
'id' => $sale->id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clean old data from planet production tax journal
|
||||||
|
$pis = PlanetProductionTaxJournal::all();
|
||||||
|
foreach($pis as $pi) {
|
||||||
|
$date = new Carbon($pi->created_at);
|
||||||
|
if($date->lessThan($ago)) {
|
||||||
|
PlanetProductionTaxJournal::where([
|
||||||
|
'id' => $pi->id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clean old data from player donation journal
|
||||||
|
$donations = PlayerDonationJournal::all();
|
||||||
|
foreach($donations as $donation) {
|
||||||
|
$date = new Carbon($donation->created_at);
|
||||||
|
if($date->lessThan($ago)) {
|
||||||
|
PlayerDonationJournal::where([
|
||||||
|
'id' => $donation->id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clean old data from Reprocessing Tax Journal
|
||||||
|
$reps = ReprocessingTaxJournal::all();
|
||||||
|
foreach($reps as $rep) {
|
||||||
|
$date = new Carbon($rep->created_at);
|
||||||
|
if($date->lessThan($ago)) {
|
||||||
|
ReprocessingTaxJournal::where([
|
||||||
|
'id' => $rep->id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clean old sov bill journal data
|
||||||
|
$sovs = SovBillJournal::all();
|
||||||
|
foreach($sovs as $sov) {
|
||||||
|
$date = new Carbon($sov->created_at);
|
||||||
|
if($date->lessThan($ago)) {
|
||||||
|
SovBillJournal::where([
|
||||||
|
'id' => $sov->id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clean old structure industry tax journal data
|
||||||
|
$industrys = StructureIndustryTaxJournal::all();
|
||||||
|
foreach($industrys as $indy) {
|
||||||
|
$date = new Carbon($indy->created_at);
|
||||||
|
if($date->lessThan($ago)) {
|
||||||
|
StructureIndustryTaxJournal::where([
|
||||||
|
'id' => $indy->id,
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class Kernel extends ConsoleKernel
|
|||||||
Commands\EmptyJumpBridges::class,
|
Commands\EmptyJumpBridges::class,
|
||||||
Commands\PurgeWormholes::class,
|
Commands\PurgeWormholes::class,
|
||||||
Commands\SovBillsCommand::class,
|
Commands\SovBillsCommand::class,
|
||||||
|
Commands\CleanStaleDataCommand::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,6 +77,10 @@ class Kernel extends ConsoleKernel
|
|||||||
//Wormhole data purge
|
//Wormhole data purge
|
||||||
$schedule->command('services:PurgeWormholeData')
|
$schedule->command('services:PurgeWormholeData')
|
||||||
->hourlyAt(20);
|
->hourlyAt(20);
|
||||||
|
//Purge old data from the database
|
||||||
|
$schedule->command('services:CleanData')
|
||||||
|
->weekly(7, '11:00')
|
||||||
|
->withoutOverlapping();
|
||||||
|
|
||||||
//Horizon Graph Schedule
|
//Horizon Graph Schedule
|
||||||
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
$schedule->command('horizon:snapshot')->everyFiveMinutes();
|
||||||
|
|||||||
Reference in New Issue
Block a user