seeder
This commit is contained in:
@@ -125,22 +125,13 @@ class MoonCalc {
|
||||
$result = $client->request('GET', $uri);
|
||||
$item = json_decode($result->getBody(), true);
|
||||
|
||||
if(DB::table('Prices')->where('Name', '=', $key)->get() == null) {
|
||||
DB::table('Prices')->insert([
|
||||
'Name' => $key,
|
||||
'ItemId' => $value,
|
||||
'Price' => $item[$value]['sell']['median'],
|
||||
'Time' => $time
|
||||
]);
|
||||
} else {
|
||||
DB::table('Prices')->where('Name', $key)->update([
|
||||
'Name' => $key,
|
||||
'ItemId' => $value,
|
||||
'Price' => $item[$value]['sell']['median'],
|
||||
'Time' => $time,
|
||||
]);
|
||||
}
|
||||
|
||||
DB::table('Prices')->where('Name', $key)->update([
|
||||
'Name' => $key,
|
||||
'ItemId' => $value,
|
||||
'Price' => $item[$value]['sell']['median'],
|
||||
'Time' => $time,
|
||||
]);
|
||||
|
||||
/*
|
||||
DB::table('Prices')->insert([
|
||||
'Name' => $key,
|
||||
@@ -149,6 +140,7 @@ class MoonCalc {
|
||||
'Time' => $time
|
||||
]);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
$this->UpdateItemPricing();
|
||||
@@ -252,25 +244,14 @@ class MoonCalc {
|
||||
//Calculate the m3 price
|
||||
$m3Price = $price / $composition[0]->m3Size;
|
||||
//Update the prices in the Prices table
|
||||
if(DB::table('OrePrices')->where('Name', '=', $composition[0]->Name)->get() == null) {
|
||||
DB::table('OrePrices')->insert([
|
||||
'Name' => $composition[0]->Name,
|
||||
'ItemId' => $composition[0]->ItemId,
|
||||
'BatchPrice' => $batchPrice,
|
||||
'UnitPrice' => $price,
|
||||
'm3Price' => $m3Price,
|
||||
]);
|
||||
} else {
|
||||
DB::table('OrePrices')->where('Name', $composition[0]->Name)->update([
|
||||
'Name' => $composition[0]->Name,
|
||||
'ItemId' => $composition[0]->ItemId,
|
||||
'BatchPrice' => $batchPrice,
|
||||
'UnitPrice' => $price,
|
||||
'm3Price' => $m3Price,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
DB::table('OrePrices')->where('Name', $composition[0]->Name)->update([
|
||||
'Name' => $composition[0]->Name,
|
||||
'ItemId' => $composition[0]->ItemId,
|
||||
'BatchPrice' => $batchPrice,
|
||||
'UnitPrice' => $price,
|
||||
'm3Price' => $m3Price,
|
||||
]);
|
||||
|
||||
/*
|
||||
//Insert the prices into the Prices table
|
||||
DB::table('OrePrices')->insert([
|
||||
|
||||
@@ -13,8 +13,9 @@ class DatabaseSeeder extends Seeder
|
||||
public function run()
|
||||
{
|
||||
$this->call([
|
||||
WikiTableSeeder::class,
|
||||
ConfigTableSeeder::class,
|
||||
//WikiTableSeeder::class,
|
||||
//ConfigTableSeeder::class,
|
||||
OrePricesSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
183
database/seeds/OrePricesSeeder.php
Normal file
183
database/seeds/OrePricesSeeder.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class OrePricesSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->FetchNewPrices();
|
||||
$this->UpdateItemPricing();
|
||||
}
|
||||
|
||||
private function UpdateItemPricing() {
|
||||
//Get the configuration from the config table
|
||||
$config = DB::table('Config')->first();
|
||||
//Calculate refine rate
|
||||
$refineRate = $config->RefineRate / 100.00;
|
||||
//Calculate the current time
|
||||
$time = time();
|
||||
//Get the max time from the database
|
||||
$maxTime = DB::table('Prices')->where('ItemId', 34)->max('Time');
|
||||
//Get the price of the basic minerals
|
||||
$tritaniumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [34, $maxTime]);
|
||||
$tritanium = DB::select( DB::raw('SELECT Price FROM Prices WHERE ItemId= :id AND Time= :time'), array('id' => 34, 'time' => $maxTime));
|
||||
$pyeritePrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [35, $maxTime]);
|
||||
$mexallonPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [36, $maxTime]);
|
||||
$isogenPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [37, $maxTime]);
|
||||
$nocxiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [38, $maxTime]);
|
||||
$zydrinePrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [39, $maxTime]);
|
||||
$megacytePrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [40, $maxTime]);
|
||||
$morphitePrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [11399, $maxTime]);
|
||||
$heliumIsotopesPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16274, $maxTime]);
|
||||
$nitrogenIsotopesPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [17888, $maxTime]);
|
||||
$oxygenIsotopesPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [17887, $maxTime]);
|
||||
$hydrogenIsotopesPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [17889, $maxTime]);
|
||||
$liquidOzonePrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16273, $maxTime]);
|
||||
$heavyWaterPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16272, $maxTime]);
|
||||
$strontiumClathratesPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16275, $maxTime]);
|
||||
//Get the price of the moongoo
|
||||
$atmosphericGasesPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16634, $maxTime]);
|
||||
$evaporiteDepositsPirce = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16635, $maxTime]);
|
||||
$hydrocarbonsPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16633, $maxTime]);
|
||||
$silicatesPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16636, $maxTime]);
|
||||
$cobaltPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16640, $maxTime]);
|
||||
$scandiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16639, $maxTime]);
|
||||
$titaniumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16638, $maxTime]);
|
||||
$tungstenPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16637, $maxTime]);
|
||||
$cadmiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16643, $maxTime]);
|
||||
$platinumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16644, $maxTime]);
|
||||
$vanadiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16642, $maxTime]);
|
||||
$chromiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16641, $maxTime]);
|
||||
$technetiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16649, $maxTime]);
|
||||
$hafniumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16648, $maxTime]);
|
||||
$caesiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16647, $maxTime]);
|
||||
$mercuryPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16646, $maxTime]);
|
||||
$dysprosiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16650, $maxTime]);
|
||||
$neodymiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16651, $maxTime]);
|
||||
$promethiumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16652, $maxTime]);
|
||||
$thuliumPrice = DB::select('SELECT Price FROM Prices WHERE ItemId = ? AND Time = ?', [16653, $maxTime]);
|
||||
//Get the item compositions
|
||||
$items = DB::select('SELECT Name,ItemId FROM ItemComposition');
|
||||
//Go through each of the items and update the price
|
||||
foreach($items as $item) {
|
||||
//Get the item composition
|
||||
$composition = DB::select('SELECT * FROM ItemComposition WHERE ItemId = ?', [$item->ItemId]);
|
||||
//Calculate the Batch Price
|
||||
$batchPrice = ( ($composition[0]->Tritanium * $tritaniumPrice[0]->Price) +
|
||||
($composition[0]->Pyerite * $pyeritePrice[0]->Price) +
|
||||
($composition[0]->Mexallon * $mexallonPrice[0]->Price) +
|
||||
($composition[0]->Isogen * $isogenPrice[0]->Price) +
|
||||
($composition[0]->Nocxium * $nocxiumPrice[0]->Price) +
|
||||
($composition[0]->Zydrine * $zydrinePrice[0]->Price) +
|
||||
($composition[0]->Megacyte * $megacytePrice[0]->Price) +
|
||||
($composition[0]->Morphite * $morphitePrice[0]->Price) +
|
||||
($composition[0]->HeavyWater * $heavyWaterPrice[0]->Price) +
|
||||
($composition[0]->LiquidOzone * $liquidOzonePrice[0]->Price) +
|
||||
($composition[0]->NitrogenIsotopes * $nitrogenIsotopesPrice[0]->Price) +
|
||||
($composition[0]->HeliumIsotopes * $heliumIsotopesPrice[0]->Price) +
|
||||
($composition[0]->HydrogenIsotopes * $hydrogenIsotopesPrice[0]->Price) +
|
||||
($composition[0]->OxygenIsotopes * $oxygenIsotopesPrice[0]->Price) +
|
||||
($composition[0]->StrontiumClathrates * $strontiumClathratesPrice[0]->Price) +
|
||||
($composition[0]->AtmosphericGases * $atmosphericGasesPrice[0]->Price) +
|
||||
($composition[0]->EvaporiteDeposits * $evaporiteDepositsPirce[0]->Price) +
|
||||
($composition[0]->Hydrocarbons * $hydrocarbonsPrice[0]->Price) +
|
||||
($composition[0]->Silicates * $silicatesPrice[0]->Price) +
|
||||
($composition[0]->Cobalt * $cobaltPrice[0]->Price) +
|
||||
($composition[0]->Scandium * $scandiumPrice[0]->Price) +
|
||||
($composition[0]->Titanium * $titaniumPrice[0]->Price) +
|
||||
($composition[0]->Tungsten * $tungstenPrice[0]->Price) +
|
||||
($composition[0]->Cadmium * $cadmiumPrice[0]->Price) +
|
||||
($composition[0]->Platinum * $platinumPrice[0]->Price) +
|
||||
($composition[0]->Vanadium * $vanadiumPrice[0]->Price) +
|
||||
($composition[0]->Chromium * $chromiumPrice[0]->Price)+
|
||||
($composition[0]->Technetium * $technetiumPrice[0]->Price) +
|
||||
($composition[0]->Hafnium * $hafniumPrice[0]->Price) +
|
||||
($composition[0]->Caesium * $caesiumPrice[0]->Price) +
|
||||
($composition[0]->Mercury * $mercuryPrice[0]->Price) +
|
||||
($composition[0]->Dysprosium * $dysprosiumPrice[0]->Price) +
|
||||
($composition[0]->Neodymium * $neodymiumPrice[0]->Price) +
|
||||
($composition[0]->Promethium * $promethiumPrice[0]->Price) +
|
||||
($composition[0]->Thulium * $thuliumPrice[0]->Price));
|
||||
//Calculate the batch price with the refine rate included
|
||||
//Batch Price is base price for everything
|
||||
$batchPrice = $batchPrice * $refineRate;
|
||||
//Calculate the unit price
|
||||
$price = $batchPrice / $composition[0]->BatchSize;
|
||||
//Calculate the m3 price
|
||||
$m3Price = $price / $composition[0]->m3Size;
|
||||
//Insert the prices into the Prices table
|
||||
DB::table('OrePrices')->insert([
|
||||
'Name' => $composition[0]->Name,
|
||||
'ItemId' => $composition[0]->ItemId,
|
||||
'BatchPrice' => $batchPrice,
|
||||
'UnitPrice' => $price,
|
||||
'm3Price' => $m3Price,
|
||||
'Time' => $time
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
private function FetchNewPrices() {
|
||||
$ItemIDs = array(
|
||||
"Tritanium" => 34,
|
||||
"Pyerite" => 35,
|
||||
"Mexallon" => 36,
|
||||
"Isogen" => 37,
|
||||
"Nocxium" => 38,
|
||||
"Zydrine" => 39,
|
||||
"Megacyte" => 40,
|
||||
"Morphite" => 11399,
|
||||
"HeliumIsotopes" => 16274,
|
||||
"NitrogenIsotopes" => 17888,
|
||||
"OxygenIsotopes" => 17887,
|
||||
"HydrogenIsotopes" => 17889,
|
||||
"LiquidOzone" => 16273,
|
||||
"HeavyWater" => 16272,
|
||||
"StrontiumClathrates" => 16275,
|
||||
"AtmosphericGases" => 16634,
|
||||
"EvaporiteDeposits" => 16635,
|
||||
"Hydrocarbons" => 16633,
|
||||
"Silicates" => 16636,
|
||||
"Cobalt" => 16640,
|
||||
"Scandium" => 16639,
|
||||
"Titanium" => 16638,
|
||||
"Tungsten" => 16637,
|
||||
"Cadmium" => 16643,
|
||||
"Platinum" => 16644,
|
||||
"Vanadium" => 16642,
|
||||
"Chromium" => 16641,
|
||||
"Technetium" => 16649,
|
||||
"Hafnium" => 16648,
|
||||
"Caesium" => 16647,
|
||||
"Mercury" => 16646,
|
||||
"Dysprosium" => 16650,
|
||||
"Neodymium" => 16651,
|
||||
"Promethium" => 16652,
|
||||
"Thulium" => 16653,
|
||||
);
|
||||
$time = time();
|
||||
$item = array();
|
||||
//Get the json data for each ItemId from https://market.fuzzwork.co.uk/api/
|
||||
//Base url is https://market.fuzzwork.co.uk/aggregates/?region=10000002&types=34
|
||||
//Going to use curl for these requests
|
||||
foreach($ItemIDs as $key => $value) {
|
||||
$client = new Client(['base_uri' => 'https://market.fuzzwork.co.uk/aggregates/']);
|
||||
$uri = '?region=10000002&types=' . $value;
|
||||
$result = $client->request('GET', $uri);
|
||||
$item = json_decode($result->getBody(), true);
|
||||
|
||||
DB::table('Prices')->insert([
|
||||
'Name' => $key,
|
||||
'ItemId' => $value,
|
||||
'Price' => $item[$value]['sell']['median'],
|
||||
'Time' => $time
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
vendor/composer/autoload_classmap.php
vendored
2
vendor/composer/autoload_classmap.php
vendored
@@ -1847,6 +1847,7 @@ return array(
|
||||
'Opis\\Closure\\SecurityProvider' => $vendorDir . '/opis/closure/src/SecurityProvider.php',
|
||||
'Opis\\Closure\\SelfReference' => $vendorDir . '/opis/closure/src/SelfReference.php',
|
||||
'Opis\\Closure\\SerializableClosure' => $vendorDir . '/opis/closure/src/SerializableClosure.php',
|
||||
'OrePricesSeeder' => $baseDir . '/database/seeds/OrePricesSeeder.php',
|
||||
'PHPUnit\\Exception' => $vendorDir . '/phpunit/phpunit/src/Exception.php',
|
||||
'PHPUnit\\Framework\\Assert' => $vendorDir . '/phpunit/phpunit/src/Framework/Assert.php',
|
||||
'PHPUnit\\Framework\\AssertionFailedError' => $vendorDir . '/phpunit/phpunit/src/Framework/AssertionFailedError.php',
|
||||
@@ -2768,6 +2769,7 @@ return array(
|
||||
'Predis\\Transaction\\AbortedMultiExecException' => $vendorDir . '/predis/predis/src/Transaction/AbortedMultiExecException.php',
|
||||
'Predis\\Transaction\\MultiExec' => $vendorDir . '/predis/predis/src/Transaction/MultiExec.php',
|
||||
'Predis\\Transaction\\MultiExecState' => $vendorDir . '/predis/predis/src/Transaction/MultiExecState.php',
|
||||
'PricesSeeder' => $baseDir . '/database/seeds/PricesSeeder.php',
|
||||
'Prophecy\\Argument' => $vendorDir . '/phpspec/prophecy/src/Prophecy/Argument.php',
|
||||
'Prophecy\\Argument\\ArgumentsWildcard' => $vendorDir . '/phpspec/prophecy/src/Prophecy/Argument/ArgumentsWildcard.php',
|
||||
'Prophecy\\Argument\\Token\\AnyValueToken' => $vendorDir . '/phpspec/prophecy/src/Prophecy/Argument/Token/AnyValueToken.php',
|
||||
|
||||
2
vendor/composer/autoload_static.php
vendored
2
vendor/composer/autoload_static.php
vendored
@@ -2242,6 +2242,7 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
|
||||
'Opis\\Closure\\SecurityProvider' => __DIR__ . '/..' . '/opis/closure/src/SecurityProvider.php',
|
||||
'Opis\\Closure\\SelfReference' => __DIR__ . '/..' . '/opis/closure/src/SelfReference.php',
|
||||
'Opis\\Closure\\SerializableClosure' => __DIR__ . '/..' . '/opis/closure/src/SerializableClosure.php',
|
||||
'OrePricesSeeder' => __DIR__ . '/../..' . '/database/seeds/OrePricesSeeder.php',
|
||||
'PHPUnit\\Exception' => __DIR__ . '/..' . '/phpunit/phpunit/src/Exception.php',
|
||||
'PHPUnit\\Framework\\Assert' => __DIR__ . '/..' . '/phpunit/phpunit/src/Framework/Assert.php',
|
||||
'PHPUnit\\Framework\\AssertionFailedError' => __DIR__ . '/..' . '/phpunit/phpunit/src/Framework/AssertionFailedError.php',
|
||||
@@ -3163,6 +3164,7 @@ class ComposerStaticInitc3f953f8a7291d41a76e1664339777c9
|
||||
'Predis\\Transaction\\AbortedMultiExecException' => __DIR__ . '/..' . '/predis/predis/src/Transaction/AbortedMultiExecException.php',
|
||||
'Predis\\Transaction\\MultiExec' => __DIR__ . '/..' . '/predis/predis/src/Transaction/MultiExec.php',
|
||||
'Predis\\Transaction\\MultiExecState' => __DIR__ . '/..' . '/predis/predis/src/Transaction/MultiExecState.php',
|
||||
'PricesSeeder' => __DIR__ . '/../..' . '/database/seeds/PricesSeeder.php',
|
||||
'Prophecy\\Argument' => __DIR__ . '/..' . '/phpspec/prophecy/src/Prophecy/Argument.php',
|
||||
'Prophecy\\Argument\\ArgumentsWildcard' => __DIR__ . '/..' . '/phpspec/prophecy/src/Prophecy/Argument/ArgumentsWildcard.php',
|
||||
'Prophecy\\Argument\\Token\\AnyValueToken' => __DIR__ . '/..' . '/phpspec/prophecy/src/Prophecy/Argument/Token/AnyValueToken.php',
|
||||
|
||||
Reference in New Issue
Block a user