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

Return equipment list in recipe response #145

Merged
merged 1 commit into from
Mar 25, 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
7 changes: 7 additions & 0 deletions backend/app/Savor22b/GraphTypes/Query/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ private List<RecipeResponse> combineRecipeData()
{
var foodDict = CsvDataHelper.GetFoodCSVData().ToDictionary(x => x.ID);
var ingredientDict = CsvDataHelper.GetIngredientCSVData().ToDictionary(x => x.ID);
var kitchenEquipmentCategoryDict = CsvDataHelper.GetKitchenEquipmentCategoryCSVData().ToDictionary(x => x.ID);

var recipes = new List<RecipeResponse>();
foreach (var recipe in CsvDataHelper.GetRecipeCSVData())
Expand All @@ -550,12 +551,18 @@ private List<RecipeResponse> combineRecipeData()
var recipeFoodComponents = recipe.FoodIDList
.Select(foodID => new RecipeComponent(foodID, foodDict[foodID].Name))
.ToList();
var requiredKitchenEquipmentCategoryComponents = recipe.RequiredKitchenEquipmentCategoryList
.Select(equipment => new RecipeComponent(equipment, kitchenEquipmentCategoryDict[equipment].Name))
.ToList();
var resultFoodComponent = new RecipeComponent(recipe.ResultFoodID, foodDict[recipe.ResultFoodID].Name);

recipes.Add(
new RecipeResponse(
recipe.ID,
recipe.Name,
recipe.RequiredBlock,
resultFoodComponent,
requiredKitchenEquipmentCategoryComponents,
recipeIngredientComponents,
recipeFoodComponents
)
Expand Down
14 changes: 13 additions & 1 deletion backend/app/Savor22b/GraphTypes/Types/RecipeGraphType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,24 @@ public RecipeResponseType()
resolve: context => context.Source.Name
);

Field<RecipeComponentType>(
name: "resultFood",
description: "The Result Food of the recipe.",
resolve: context => context.Source.ResultFood
);

Field<IntGraphType>(
name: "required",
name: "requiredBlockCount",
description: "The RequiredBlock of the recipe.",
resolve: context => context.Source.RequiredBlock
);

Field<ListGraphType<RecipeComponentType>>(
name: "requiredKitchenEquipmentCategoryList",
description: "The list of ingredients in the recipe.",
resolve: context => context.Source.RequiredKitchenEquipmentCategoryList.ToList()
);

Field<ListGraphType<RecipeComponentType>>(
name: "ingredientIDList",
description: "The list of ingredients in the recipe.",
Expand Down
8 changes: 8 additions & 0 deletions backend/app/Savor22b/GraphTypes/Types/RecipeResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ public RecipeResponse(
int id,
string name,
int requiredBlock,
RecipeComponent resultFood,
List<RecipeComponent> requiredKitchenEquipmentCategoryList,
List<RecipeComponent> ingredientList,
List<RecipeComponent> foodList
)
{
Id = id;
Name = name;
RequiredBlock = requiredBlock;
ResultFood = resultFood;
RequiredKitchenEquipmentCategoryList = requiredKitchenEquipmentCategoryList;
IngredientList = ingredientList;
FoodList = foodList;
}
Expand All @@ -23,6 +27,10 @@ List<RecipeComponent> foodList

public int RequiredBlock { get; set; }

public RecipeComponent ResultFood { get; set; }

public List<RecipeComponent> RequiredKitchenEquipmentCategoryList { get; set; }

public List<RecipeComponent> IngredientList { get; set; }

public List<RecipeComponent> FoodList { get; set; }
Expand Down
Loading