mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Added data_generation_scripts
This commit is contained in:
parent
282168f92c
commit
01ddeb4dfd
27
.devtools/data_generation_scripts/9999_big_stock.php
Normal file
27
.devtools/data_generation_scripts/9999_big_stock.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
// This is executed inside DatabaseMigrationService class/context
|
||||
|
||||
use Grocy\Services\StockService;
|
||||
|
||||
$PRODUCTS = [3, 4, 5, 6, 7, 8];
|
||||
|
||||
$i = 1;
|
||||
$days = -1;
|
||||
while ($i <= 500)
|
||||
{
|
||||
$productId = $PRODUCTS[array_rand($PRODUCTS)];
|
||||
$transactionId1 = $this->getStockService()->AddProduct($productId, 1, date('Y-m-d', strtotime('+180 days')), StockService::TRANSACTION_TYPE_PURCHASE, date('Y-m-d', strtotime("$days days")), XRandomPrice());
|
||||
$transactionId2 = $this->getStockService()->ConsumeProduct($productId, 1, false, StockService::TRANSACTION_TYPE_CONSUME);
|
||||
|
||||
$this->getDatabaseService()->ExecuteDbStatement("UPDATE stock_log SET row_created_timestamp = DATETIME(row_created_timestamp, '$days days') WHERE transaction_id = '$transactionId1'");
|
||||
$this->getDatabaseService()->ExecuteDbStatement("UPDATE stock_log SET row_created_timestamp = DATETIME(row_created_timestamp, '$days days') WHERE transaction_id = '$transactionId2'");
|
||||
|
||||
$days--;
|
||||
$i++;
|
||||
}
|
||||
|
||||
function XRandomPrice()
|
||||
{
|
||||
return mt_rand(2 * 100, 25 * 100) / 100 / 4;
|
||||
}
|
16
.devtools/data_generation_scripts/9999_lots_recipes.php
Normal file
16
.devtools/data_generation_scripts/9999_lots_recipes.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
// This is executed inside DatabaseMigrationService class/context
|
||||
|
||||
use Grocy\Services\RecipesService;
|
||||
|
||||
$recipesService = RecipesService::getInstance();
|
||||
|
||||
for ($i = 1; $i <= 87; $i++)
|
||||
{
|
||||
$recipesService->CopyRecipe(1);
|
||||
$recipesService->CopyRecipe(2);
|
||||
$recipesService->CopyRecipe(3);
|
||||
$recipesService->CopyRecipe(4);
|
||||
$recipesService->CopyRecipe(5);
|
||||
}
|
BIN
.devtools/data_generation_scripts/big_meal_plan.xlsx
Normal file
BIN
.devtools/data_generation_scripts/big_meal_plan.xlsx
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user