mirror of
				https://github.com/mealie-recipes/mealie.git
				synced 2025-10-31 10:13:32 -04:00 
			
		
		
		
	fix: send the correct value for recipe scale and ensure the body is sent correctly (#5737)
This commit is contained in:
		| @@ -1,6 +1,5 @@ | ||||
| import { useStoreActions } from "./partials/use-actions-factory"; | ||||
| import { useUserApi } from "~/composables/api"; | ||||
| import { useScaledAmount } from "~/composables/recipes/use-scaled-amount"; | ||||
| import type { GroupRecipeActionOut, GroupRecipeActionType } from "~/lib/api/types/household"; | ||||
| import type { RequestResponse } from "~/lib/api/types/non-generated"; | ||||
| import type { Recipe } from "~/lib/api/types/recipe"; | ||||
| @@ -68,7 +67,7 @@ export const useGroupRecipeActions = function ( | ||||
|         window.open(url, "_blank")?.focus(); | ||||
|         return; | ||||
|       case "post": | ||||
|         return await api.groupRecipeActions.triggerAction(action.id, recipe.slug || "", useScaledAmount(recipe.recipeServings || 1, recipeScale).scaledAmount); | ||||
|         return await api.groupRecipeActions.triggerAction(action.id, recipe.slug || "", recipeScale); | ||||
|       default: | ||||
|         break; | ||||
|     } | ||||
|   | ||||
| @@ -13,7 +13,7 @@ export class GroupRecipeActionsAPI extends BaseCRUDAPI<CreateGroupRecipeAction, | ||||
|   baseRoute = routes.groupRecipeActions; | ||||
|   itemRoute = routes.groupRecipeActionsId; | ||||
|  | ||||
|   async triggerAction(id: string | number, recipeSlug: string, scaledAmount: number) { | ||||
|     return await this.requests.post(routes.groupRecipeActionsIdTriggerRecipeSlug(id, recipeSlug), { scaledAmount }); | ||||
|   async triggerAction(id: string | number, recipeSlug: string, recipeScale: number) { | ||||
|     return await this.requests.post(routes.groupRecipeActionsIdTriggerRecipeSlug(id, recipeSlug), { recipe_scale: recipeScale }); | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -69,7 +69,7 @@ class GroupRecipeActionController(BaseUserController): | ||||
|  | ||||
|     @router.post("/{item_id}/trigger/{recipe_slug}", status_code=202) | ||||
|     def trigger_action( | ||||
|         self, item_id: UUID4, recipe_slug: str, bg_tasks: BackgroundTasks, scaled_amount: float = Body(1, embed=True) | ||||
|         self, item_id: UUID4, recipe_slug: str, bg_tasks: BackgroundTasks, recipe_scale: float = Body(1, embed=True) | ||||
|     ) -> None: | ||||
|         recipe_action = self.repos.group_recipe_actions.get_one(item_id) | ||||
|         if not recipe_action: | ||||
| @@ -95,7 +95,7 @@ class GroupRecipeActionController(BaseUserController): | ||||
|                 detail=ErrorResponse.respond(message="Not found."), | ||||
|             ) from e | ||||
|  | ||||
|         payload = GroupRecipeActionPayload(action=recipe_action, content=recipe, scaled_amount=scaled_amount) | ||||
|         payload = GroupRecipeActionPayload(action=recipe_action, content=recipe, recipe_scale=recipe_scale) | ||||
|         bg_tasks.add_task( | ||||
|             task_action, | ||||
|             url=recipe_action.url, | ||||
|   | ||||
| @@ -44,4 +44,4 @@ class GroupRecipeActionPagination(PaginationBase): | ||||
| class GroupRecipeActionPayload(MealieModel): | ||||
|     action: GroupRecipeActionOut | ||||
|     content: Any | ||||
|     scaled_amount: float | ||||
|     recipe_scale: float | ||||
|   | ||||
| @@ -173,7 +173,7 @@ def test_group_recipe_actions_trigger_post( | ||||
|     response = api_client.post( | ||||
|         api_routes.households_recipe_actions_item_id_trigger_recipe_slug(action_id, recipe_slug), | ||||
|         headers=unique_user.token, | ||||
|         json={"scaled_amount": 1.0}, | ||||
|         json={"recipe_scale": 1.0}, | ||||
|     ) | ||||
|  | ||||
|     if missing_action or missing_recipe: | ||||
| @@ -190,7 +190,7 @@ def test_group_recipe_actions_trigger_invalid_type(api_client: TestClient, uniqu | ||||
|     response = api_client.post( | ||||
|         api_routes.households_recipe_actions_item_id_trigger_recipe_slug(recipe_action.id, recipe.id), | ||||
|         headers=unique_user.token, | ||||
|         json={"scaled_amount": 1.0}, | ||||
|         json={"recipe_scale": 1.0}, | ||||
|     ) | ||||
|  | ||||
|     assert response.status_code == 400 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user