Remove unused fields

This commit is contained in:
Kirill Kamakin
2022-10-30 12:44:33 +01:00
parent 9ed229f20f
commit 31ccf8822d
12 changed files with 390 additions and 256 deletions

View File

@@ -3,44 +3,21 @@ package gq.kirmanak.mealient.data.add
data class AddRecipeInfo(
val name: String = "",
val description: String = "",
val image: String = "",
val recipeYield: String = "",
val recipeIngredient: List<AddRecipeIngredientInfo> = emptyList(),
val recipeInstructions: List<AddRecipeInstructionInfo> = emptyList(),
val slug: String = "",
val filePath: String = "",
val tags: List<String> = emptyList(),
val categories: List<String> = emptyList(),
val notes: List<AddRecipeNoteInfo> = emptyList(),
val extras: Map<String, String> = emptyMap(),
val assets: List<String> = emptyList(),
val settings: AddRecipeSettingsInfo = AddRecipeSettingsInfo(),
)
data class AddRecipeSettingsInfo(
val disableAmount: Boolean = true,
val disableComments: Boolean = false,
val landscapeView: Boolean = true,
val public: Boolean = true,
val showAssets: Boolean = true,
val showNutrition: Boolean = true,
)
data class AddRecipeNoteInfo(
val title: String = "",
val text: String = "",
)
data class AddRecipeIngredientInfo(
val disableAmount: Boolean = true,
val food: String? = null,
val note: String = "",
val quantity: Int = 1,
val title: String? = null,
val unit: String? = null,
)
data class AddRecipeInstructionInfo(
val title: String = "",
val text: String = "",
)

View File

@@ -1,34 +1,17 @@
package gq.kirmanak.mealient.data.recipes.network
import kotlinx.datetime.LocalDate
import kotlinx.datetime.LocalDateTime
data class FullRecipeInfo(
val remoteId: String,
val name: String,
val slug: String,
val image: String?,
val description: String,
val recipeCategories: List<String>,
val tags: List<String>,
val rating: Int?,
val dateAdded: LocalDate,
val dateUpdated: LocalDateTime,
val recipeYield: String,
val recipeIngredients: List<RecipeIngredientInfo>,
val recipeInstructions: List<RecipeInstructionInfo>,
)
data class RecipeIngredientInfo(
val title: String,
val note: String,
val unit: String,
val food: String,
val disableAmount: Boolean,
val quantity: Double,
)
data class RecipeInstructionInfo(
val title: String,
val text: String,
)

View File

@@ -1,6 +1,9 @@
package gq.kirmanak.mealient.extensions
import gq.kirmanak.mealient.data.add.*
import gq.kirmanak.mealient.data.add.AddRecipeInfo
import gq.kirmanak.mealient.data.add.AddRecipeIngredientInfo
import gq.kirmanak.mealient.data.add.AddRecipeInstructionInfo
import gq.kirmanak.mealient.data.add.AddRecipeSettingsInfo
import gq.kirmanak.mealient.data.baseurl.VersionInfo
import gq.kirmanak.mealient.data.recipes.network.FullRecipeInfo
import gq.kirmanak.mealient.data.recipes.network.RecipeIngredientInfo
@@ -21,17 +24,11 @@ fun FullRecipeInfo.toRecipeEntity() = RecipeEntity(
fun RecipeIngredientInfo.toRecipeIngredientEntity(remoteId: String) = RecipeIngredientEntity(
recipeId = remoteId,
title = title,
note = note,
unit = unit,
food = food,
disableAmount = disableAmount,
quantity = quantity
)
fun RecipeInstructionInfo.toRecipeInstructionEntity(remoteId: String) = RecipeInstructionEntity(
recipeId = remoteId,
title = title,
text = text
)
@@ -104,105 +101,54 @@ fun AddRecipeInfo.toDraft(): AddRecipeDraft = AddRecipeDraft(
fun GetRecipeResponseV0.toFullRecipeInfo() = FullRecipeInfo(
remoteId = remoteId.toString(),
name = name,
slug = slug,
image = image,
description = description,
recipeCategories = recipeCategories,
tags = tags,
rating = rating,
dateAdded = dateAdded,
dateUpdated = dateUpdated,
recipeYield = recipeYield,
recipeIngredients = recipeIngredients.map { it.toRecipeIngredientInfo() },
recipeInstructions = recipeInstructions.map { it.toRecipeInstructionInfo() }
)
fun GetRecipeIngredientResponseV0.toRecipeIngredientInfo() = RecipeIngredientInfo(
title = title,
note = note,
unit = unit,
food = food,
disableAmount = disableAmount,
quantity = quantity
)
fun GetRecipeInstructionResponseV0.toRecipeInstructionInfo() = RecipeInstructionInfo(
title = title,
text = text
)
fun GetRecipeResponseV1.toFullRecipeInfo() = FullRecipeInfo(
remoteId = remoteId,
name = name,
slug = slug,
image = image,
description = description,
recipeCategories = recipeCategories,
tags = tags,
rating = rating,
dateAdded = dateAdded,
dateUpdated = dateUpdated,
recipeYield = recipeYield,
recipeIngredients = recipeIngredients.map { it.toRecipeIngredientInfo() },
recipeInstructions = recipeInstructions.map { it.toRecipeInstructionInfo() }
)
fun GetRecipeIngredientResponseV1.toRecipeIngredientInfo() = RecipeIngredientInfo(
title = title,
note = note,
unit = unit,
food = food,
disableAmount = disableAmount,
quantity = quantity
)
fun GetRecipeInstructionResponseV1.toRecipeInstructionInfo() = RecipeInstructionInfo(
title = title,
text = text
)
fun AddRecipeInfo.toV0Request() = AddRecipeRequestV0(
name = name,
description = description,
image = image,
recipeYield = recipeYield,
recipeIngredient = recipeIngredient.map { it.toV0Ingredient() },
recipeInstructions = recipeInstructions.map { it.toV0Instruction() },
slug = slug,
filePath = filePath,
tags = tags,
categories = categories,
notes = notes.map { it.toV0Note() },
extras = extras,
assets = assets,
settings = settings.toV0Settings(),
)
private fun AddRecipeSettingsInfo.toV0Settings() = AddRecipeSettingsV0(
disableAmount = disableAmount,
disableComments = disableComments,
landscapeView = landscapeView,
public = public,
showAssets = showAssets,
showNutrition = showNutrition,
)
private fun AddRecipeNoteInfo.toV0Note() = AddRecipeNoteV0(
title = title,
text = text,
)
private fun AddRecipeIngredientInfo.toV0Ingredient() = AddRecipeIngredientV0(
disableAmount = disableAmount,
food = food,
note = note,
quantity = quantity,
title = title,
unit = unit
)
private fun AddRecipeInstructionInfo.toV0Instruction() = AddRecipeInstructionV0(
title = title,
text = text,
)
@@ -213,44 +159,22 @@ fun AddRecipeInfo.toV1CreateRequest() = CreateRecipeRequestV1(
fun AddRecipeInfo.toV1UpdateRequest() = UpdateRecipeRequestV1(
description = description,
image = image,
recipeYield = recipeYield,
recipeIngredient = recipeIngredient.map { it.toV1Ingredient() },
recipeInstructions = recipeInstructions.map { it.toV1Instruction() },
filePath = filePath,
tags = tags,
categories = categories,
notes = notes.map { it.toV1Note() },
extras = extras,
assets = assets,
settings = settings.toV1Settings(),
)
private fun AddRecipeSettingsInfo.toV1Settings() = AddRecipeSettingsV1(
disableAmount = disableAmount,
disableComments = disableComments,
landscapeView = landscapeView,
public = public,
showAssets = showAssets,
showNutrition = showNutrition,
)
private fun AddRecipeNoteInfo.toV1Note() = AddRecipeNoteV1(
title = title,
text = text,
)
private fun AddRecipeIngredientInfo.toV1Ingredient() = AddRecipeIngredientV1(
disableAmount = disableAmount,
food = food,
note = note,
quantity = quantity,
title = title,
unit = unit
)
private fun AddRecipeInstructionInfo.toV1Instruction() = AddRecipeInstructionV1(
title = title,
text = text,
ingredientReferences = emptyList(),
)