created get market region order job
created purge market region order job to get rid of old useless data removed market price and market group from database tables
This commit is contained in:
@@ -1,62 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Market;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
class GetMarketGroupsJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Setup the esi authentication container
|
||||
$esi = new Esi();
|
||||
|
||||
$groups = $esi->invoke('get', '/markets/groups/');
|
||||
|
||||
foreach($groups as $group) {
|
||||
$grpResponse = $esi->invoke('get', '/markets/groups/{market_group_id}/', [
|
||||
'market_group_id' => $group,
|
||||
]);
|
||||
|
||||
foreach($grpResponse->types as $type) {
|
||||
MarketGroup::insertOrIgnore([
|
||||
'group' => $group,
|
||||
'description' => $grpResponse->description,
|
||||
'market_group_id' => $grpResponse->market_group_id,
|
||||
'name' => $grpResponse->name,
|
||||
'parent_group_id' => $grpResponse->parent_group_id,
|
||||
'type' => $type,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,14 +20,27 @@ class GetMarketRegionOrderJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Private variables
|
||||
*/
|
||||
private $esi;
|
||||
private $region;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct($region, $esi = null)
|
||||
{
|
||||
//
|
||||
//Setup the region variable
|
||||
$this->region = $region;
|
||||
//Setup the esi variable
|
||||
if($esi == null) {
|
||||
$this->esi = new Esi();
|
||||
} else {
|
||||
$this->esi = $esi;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,6 +50,55 @@ class GetMarketRegionOrderJob implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
//Get the market orders for a region
|
||||
$orders = $this->esi->invoke('get', '/markets/{region_id}/orders/', [
|
||||
'region_id' => $this->region,
|
||||
]);
|
||||
|
||||
foreach($orders as $order) {
|
||||
$count = MarketRegionOrder::where([
|
||||
'order_id',
|
||||
])->count();
|
||||
|
||||
if($count == 0) {
|
||||
$newOrder = new MarketRegionOrder;
|
||||
$newOrder->region_id = $this->region;
|
||||
$newOrder->duration = $order->duration;
|
||||
$newOrder->is_buy_order = $order->is_buy_order;
|
||||
$newOrder->issued = $order->issued;
|
||||
$newOrder->location_id = $order->location_id;
|
||||
$newOrder->min_volume = $order->min_volume;
|
||||
$newOrder->order_id = $order->order_id;
|
||||
$newOrder->price = $order->price;
|
||||
$newOrder->range = $order->range;
|
||||
$newOrder->system_id = $order->system_id;
|
||||
$newOrder->type_id = $order->type_id;
|
||||
$newOrder->volume_remain = $order->volume_remain;
|
||||
$newOrder->volume_total = $order->volume_total;
|
||||
$newOrder->save();
|
||||
} else if ($order->volume_remain == 0) {
|
||||
MarketRegionOrder::where([
|
||||
'order_id' => $order->order_id,
|
||||
])->delete();
|
||||
} else {
|
||||
MarketRegionOrder::where([
|
||||
'order_id' => $order->order_id,
|
||||
])->update([
|
||||
'region_id' => $this->region,
|
||||
'duration' => $order->duration,
|
||||
'is_buy_order' => $order->is_buy_order,
|
||||
'issued' => $order->issued,
|
||||
'location_id' => $order->location_id,
|
||||
'min_volume' => $order->min_volume,
|
||||
'order_id' => $order->order_id,
|
||||
'price' => $order->price,
|
||||
'range' => $order->range,
|
||||
'system_id' => $order->system_id,
|
||||
'type_id' => $order->type_id,
|
||||
'volume_remain' => $order->volume_remain,
|
||||
'volume_total' => $order->volume_total,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Market;
|
||||
namespace App\Jobs;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Carbon\Carbon;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
class GetMarketPricesJob implements ShouldQueue
|
||||
class PurgeMarketRegionOrderJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
@@ -24,6 +24,5 @@ class MarketPrice extends Model
|
||||
'lowest_price',
|
||||
'highest_price',
|
||||
'order_count',
|
||||
'volume',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ class MarketRegionOrder extends Model
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'region_id',
|
||||
'duration',
|
||||
'is_buy_order',
|
||||
'issued',
|
||||
|
||||
@@ -66,35 +66,10 @@ class CreateBuyPublicContractsTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('market_groups')) {
|
||||
Schema::create('market_groups', function (Blueprint $table) {
|
||||
$table->unsignedIncrements('id');
|
||||
$table->unsignedInteger('group');
|
||||
$table->string('description');
|
||||
$table->unsignedInteger('market_group_id');
|
||||
$table->string('name');
|
||||
$table->unsignedInteger('parent_group_id')->nullable();
|
||||
$table->unsignedInteger('types');
|
||||
});
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('market_prices')) {
|
||||
Schema::create('market_prices', function (Blueprint $table) {
|
||||
$table->unsignedBigIncrements('id');
|
||||
$table->unsignedInteger('type_id');
|
||||
$table->decimal('adjusted_price')->default(0.00);
|
||||
$table->decimal('average_price')->default(0.00);
|
||||
$table->decimal('lowest_price')->default(0.00);
|
||||
$table->decimal('highest_price')->default(0.00);
|
||||
$table->unsignedBigInteger('order_count');
|
||||
$table->unsignedBigInteger('volume');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
if(!Schema::hasTable('market_region_orders')) {
|
||||
Schema::create('market_region_orders', function (Blueprint $table) {
|
||||
$table->unsignedBigIncrements('id');
|
||||
$table->unsignedBigInteger('region_id');
|
||||
$table->unsignedInteger('duration');
|
||||
$table->boolean('is_buy_order');
|
||||
$table->dateTime('issued');
|
||||
|
||||
Reference in New Issue
Block a user