Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export data fix #327

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v3.19.1
## Fixes
- Fix missing base data in recipes export

# v3.19.0
## New
- Updated the way OpenAPI specification is generated
Expand Down
2 changes: 1 addition & 1 deletion app/External/Export/ToDataPack.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private function prepareDataOutput(ExportTypeEnum $type, array $data): string
{
return match ($type) {
ExportTypeEnum::JSON => json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
ExportTypeEnum::YAML => Yaml::dump($data, 8, 4, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK),
ExportTypeEnum::YAML => Yaml::dump($data, 8, 4, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK | Yaml::DUMP_OBJECT_AS_MAP),
};
}
}
8 changes: 4 additions & 4 deletions app/Scraper/Sites/ImbibeMagazine.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function glass(): ?string
});

if ($result === null) {
foreach($this->getLegacyRecipeIngredients() as $line) {
foreach ($this->getLegacyRecipeIngredients() as $line) {
if (str_starts_with($line, 'Glass:')) {
$result = str_replace('Glass:', '', $line);
}
Expand All @@ -85,7 +85,7 @@ public function ingredients(): array
}

if (empty($result)) {
foreach($this->getLegacyRecipeIngredients() as $line) {
foreach ($this->getLegacyRecipeIngredients() as $line) {
if (str_starts_with($line, 'Tools:') || str_starts_with($line, 'Garnish:') || str_starts_with($line, 'Glass:')) {
continue;
}
Expand All @@ -109,7 +109,7 @@ public function garnish(): ?string
});

if ($result === null) {
foreach($this->getLegacyRecipeIngredients() as $line) {
foreach ($this->getLegacyRecipeIngredients() as $line) {
if (str_starts_with($line, 'Garnish:')) {
$result = str_replace('Garnish:', '', $line);
}
Expand Down Expand Up @@ -164,7 +164,7 @@ private function getLegacyRecipeIngredients(): array
try {
$ingredientsParagraph = $this->crawler->filterXPath('//div[contains(@class, \'recipe__main-content\')]')->first()->filterXPath('//p[2]')->html();
$ingredientsParagraphLines = explode('<br>', $ingredientsParagraph);
foreach($ingredientsParagraphLines as $line) {
foreach ($ingredientsParagraphLines as $line) {
$result[] = trim($line);
}
} catch (\Throwable) {
Expand Down
6 changes: 3 additions & 3 deletions app/Services/IngredientService.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public function createIngredient(IngredientDTO $dto): Ingredient
$ingredient->created_user_id = $dto->userId;
$ingredient->save();

foreach($dto->complexIngredientParts as $ingredientPartId) {
foreach ($dto->complexIngredientParts as $ingredientPartId) {
$part = new ComplexIngredient();
$part->ingredient_id = $ingredientPartId;
$part->main_ingredient_id = $ingredient->id;
$part->save();
}

foreach($dto->prices as $ingredientPriceDto) {
foreach ($dto->prices as $ingredientPriceDto) {
$price = new IngredientPrice();
$price->ingredient_id = $ingredient->id;
$price->price_category_id = $ingredientPriceDto->priceCategoryId;
Expand Down Expand Up @@ -118,7 +118,7 @@ public function updateIngredient(int $id, IngredientDTO $dto): Ingredient

if (count($dto->prices) > 0) {
$ingredient->prices()->delete();
foreach($dto->prices as $ingredientPriceDto) {
foreach ($dto->prices as $ingredientPriceDto) {
$price = new IngredientPrice();
$price->ingredient_id = $ingredient->id;
$price->price_category_id = $ingredientPriceDto->priceCategoryId;
Expand Down
Loading