diff --git a/app/src/main/java/gq/kirmanak/mealient/data/add/AddRecipeInfo.kt b/app/src/main/java/gq/kirmanak/mealient/data/add/AddRecipeInfo.kt index 69c2ee9..a6283e3 100644 --- a/app/src/main/java/gq/kirmanak/mealient/data/add/AddRecipeInfo.kt +++ b/app/src/main/java/gq/kirmanak/mealient/data/add/AddRecipeInfo.kt @@ -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 = emptyList(), val recipeInstructions: List = emptyList(), - val slug: String = "", - val filePath: String = "", - val tags: List = emptyList(), - val categories: List = emptyList(), - val notes: List = emptyList(), - val extras: Map = emptyMap(), - val assets: List = 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 = "", ) diff --git a/app/src/main/java/gq/kirmanak/mealient/data/recipes/network/FullRecipeInfo.kt b/app/src/main/java/gq/kirmanak/mealient/data/recipes/network/FullRecipeInfo.kt index 25b5705..756e4ac 100644 --- a/app/src/main/java/gq/kirmanak/mealient/data/recipes/network/FullRecipeInfo.kt +++ b/app/src/main/java/gq/kirmanak/mealient/data/recipes/network/FullRecipeInfo.kt @@ -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, - val tags: List, - val rating: Int?, - val dateAdded: LocalDate, - val dateUpdated: LocalDateTime, val recipeYield: String, val recipeIngredients: List, val recipeInstructions: List, ) 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, ) diff --git a/app/src/main/java/gq/kirmanak/mealient/extensions/RemoteToLocalMappings.kt b/app/src/main/java/gq/kirmanak/mealient/extensions/RemoteToLocalMappings.kt index 84dea9b..9a95a2d 100644 --- a/app/src/main/java/gq/kirmanak/mealient/extensions/RemoteToLocalMappings.kt +++ b/app/src/main/java/gq/kirmanak/mealient/extensions/RemoteToLocalMappings.kt @@ -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(), ) \ No newline at end of file diff --git a/app/src/test/java/gq/kirmanak/mealient/test/RecipeImplTestData.kt b/app/src/test/java/gq/kirmanak/mealient/test/RecipeImplTestData.kt index 9608cfc..d4ab9e1 100644 --- a/app/src/test/java/gq/kirmanak/mealient/test/RecipeImplTestData.kt +++ b/app/src/test/java/gq/kirmanak/mealient/test/RecipeImplTestData.kt @@ -64,58 +64,32 @@ object RecipeImplTestData { ) private val SUGAR_INGREDIENT = RecipeIngredientInfo( - title = "Sugar", note = "2 oz of white sugar", - unit = "", - food = "", - disableAmount = true, - quantity = 1.0 ) val BREAD_INGREDIENT = RecipeIngredientInfo( - title = "Bread", note = "2 oz of white bread", - unit = "", - food = "", - disableAmount = false, - quantity = 2.0 ) private val MILK_INGREDIENT = RecipeIngredientInfo( - title = "Milk", note = "2 oz of white milk", - unit = "", - food = "", - disableAmount = true, - quantity = 3.0 ) val MIX_INSTRUCTION = RecipeInstructionInfo( - title = "Mix", text = "Mix the ingredients" ) private val BAKE_INSTRUCTION = RecipeInstructionInfo( - title = "Bake", text = "Bake the ingredients" ) private val BOIL_INSTRUCTION = RecipeInstructionInfo( - title = "Boil", text = "Boil the ingredients" ) val GET_CAKE_RESPONSE = FullRecipeInfo( remoteId = "1", name = "Cake", - slug = "cake", - image = "86", - description = "A tasty cake", - recipeCategories = listOf("dessert", "tasty"), - tags = listOf("gluten", "allergic"), - rating = 4, - dateAdded = LocalDate.parse("2021-11-13"), - dateUpdated = LocalDateTime.parse("2021-11-13T15:30:13"), recipeYield = "4 servings", recipeIngredients = listOf(SUGAR_INGREDIENT, BREAD_INGREDIENT), recipeInstructions = listOf(MIX_INSTRUCTION, BAKE_INSTRUCTION) @@ -124,14 +98,6 @@ object RecipeImplTestData { val GET_PORRIDGE_RESPONSE = FullRecipeInfo( remoteId = "2", name = "Porridge", - slug = "porridge", - image = "89", - description = "A tasty porridge", - recipeCategories = listOf("porridge", "tasty"), - tags = listOf("gluten", "milk"), - rating = 5, - dateAdded = LocalDate.parse("2021-11-12"), - dateUpdated = LocalDateTime.parse("2021-10-13T17:35:23"), recipeYield = "3 servings", recipeIngredients = listOf(SUGAR_INGREDIENT, MILK_INGREDIENT), recipeInstructions = listOf(MIX_INSTRUCTION, BOIL_INSTRUCTION) @@ -140,14 +106,12 @@ object RecipeImplTestData { val MIX_CAKE_RECIPE_INSTRUCTION_ENTITY = RecipeInstructionEntity( localId = 1, recipeId = "1", - title = "Mix", text = "Mix the ingredients", ) private val BAKE_CAKE_RECIPE_INSTRUCTION_ENTITY = RecipeInstructionEntity( localId = 2, recipeId = "1", - title = "Bake", text = "Bake the ingredients", ) @@ -159,23 +123,13 @@ object RecipeImplTestData { private val CAKE_SUGAR_RECIPE_INGREDIENT_ENTITY = RecipeIngredientEntity( localId = 1, recipeId = "1", - title = "Sugar", note = "2 oz of white sugar", - unit = "", - food = "", - disableAmount = true, - quantity = 1.0 ) val CAKE_BREAD_RECIPE_INGREDIENT_ENTITY = RecipeIngredientEntity( localId = 2, recipeId = "1", - title = "Bread", note = "2 oz of white bread", - unit = "", - food = "", - disableAmount = false, - quantity = 2.0 ) val FULL_CAKE_INFO_ENTITY = FullRecipeEntity( @@ -199,36 +153,24 @@ object RecipeImplTestData { private val PORRIDGE_MILK_RECIPE_INGREDIENT_ENTITY = RecipeIngredientEntity( localId = 4, recipeId = "2", - title = "Milk", note = "2 oz of white milk", - unit = "", - food = "", - disableAmount = true, - quantity = 3.0 ) private val PORRIDGE_SUGAR_RECIPE_INGREDIENT_ENTITY = RecipeIngredientEntity( localId = 3, recipeId = "2", - title = "Sugar", note = "2 oz of white sugar", - unit = "", - food = "", - disableAmount = true, - quantity = 1.0 ) private val PORRIDGE_MIX_RECIPE_INSTRUCTION_ENTITY = RecipeInstructionEntity( localId = 3, recipeId = "2", - title = "Mix", text = "Mix the ingredients" ) private val PORRIDGE_BOIL_RECIPE_INSTRUCTION_ENTITY = RecipeInstructionEntity( localId = 4, recipeId = "2", - title = "Boil", text = "Boil the ingredients" ) diff --git a/database/schemas/gq.kirmanak.mealient.database.AppDb/5.json b/database/schemas/gq.kirmanak.mealient.database.AppDb/5.json new file mode 100644 index 0000000..00986f8 --- /dev/null +++ b/database/schemas/gq.kirmanak.mealient.database.AppDb/5.json @@ -0,0 +1,374 @@ +{ + "formatVersion": 1, + "database": { + "version": 5, + "identityHash": "e75a1e16503fdf60c62b7f9d17ec0bc6", + "entities": [ + { + "tableName": "categories", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`local_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL)", + "fields": [ + { + "fieldPath": "localId", + "columnName": "local_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "local_id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_categories_name", + "unique": true, + "columnNames": [ + "name" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_categories_name` ON `${TABLE_NAME}` (`name`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "category_recipe", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`category_id` INTEGER NOT NULL, `recipe_id` TEXT NOT NULL, PRIMARY KEY(`category_id`, `recipe_id`), FOREIGN KEY(`category_id`) REFERENCES `categories`(`local_id`) ON UPDATE CASCADE ON DELETE CASCADE , FOREIGN KEY(`recipe_id`) REFERENCES `recipe_summaries`(`remote_id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "categoryId", + "columnName": "category_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "recipeId", + "columnName": "recipe_id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "category_id", + "recipe_id" + ], + "autoGenerate": false + }, + "indices": [ + { + "name": "index_category_recipe_category_id_recipe_id", + "unique": true, + "columnNames": [ + "category_id", + "recipe_id" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_category_recipe_category_id_recipe_id` ON `${TABLE_NAME}` (`category_id`, `recipe_id`)" + }, + { + "name": "index_category_recipe_recipe_id", + "unique": false, + "columnNames": [ + "recipe_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_category_recipe_recipe_id` ON `${TABLE_NAME}` (`recipe_id`)" + } + ], + "foreignKeys": [ + { + "table": "categories", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "category_id" + ], + "referencedColumns": [ + "local_id" + ] + }, + { + "table": "recipe_summaries", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "recipe_id" + ], + "referencedColumns": [ + "remote_id" + ] + } + ] + }, + { + "tableName": "tags", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`local_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL)", + "fields": [ + { + "fieldPath": "localId", + "columnName": "local_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "local_id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_tags_name", + "unique": true, + "columnNames": [ + "name" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_tags_name` ON `${TABLE_NAME}` (`name`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "tag_recipe", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`tag_id` INTEGER NOT NULL, `recipe_id` TEXT NOT NULL, PRIMARY KEY(`tag_id`, `recipe_id`), FOREIGN KEY(`tag_id`) REFERENCES `tags`(`local_id`) ON UPDATE CASCADE ON DELETE CASCADE , FOREIGN KEY(`recipe_id`) REFERENCES `recipe_summaries`(`remote_id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "tagId", + "columnName": "tag_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "recipeId", + "columnName": "recipe_id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "tag_id", + "recipe_id" + ], + "autoGenerate": false + }, + "indices": [ + { + "name": "index_tag_recipe_recipe_id", + "unique": false, + "columnNames": [ + "recipe_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_tag_recipe_recipe_id` ON `${TABLE_NAME}` (`recipe_id`)" + } + ], + "foreignKeys": [ + { + "table": "tags", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "tag_id" + ], + "referencedColumns": [ + "local_id" + ] + }, + { + "table": "recipe_summaries", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "recipe_id" + ], + "referencedColumns": [ + "remote_id" + ] + } + ] + }, + { + "tableName": "recipe_summaries", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`remote_id` TEXT NOT NULL, `name` TEXT NOT NULL, `slug` TEXT NOT NULL, `image` TEXT, `description` TEXT NOT NULL, `rating` INTEGER, `date_added` INTEGER NOT NULL, `date_updated` INTEGER NOT NULL, `image_id` TEXT, PRIMARY KEY(`remote_id`))", + "fields": [ + { + "fieldPath": "remoteId", + "columnName": "remote_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "slug", + "columnName": "slug", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "image", + "columnName": "image", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "description", + "columnName": "description", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "rating", + "columnName": "rating", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "dateAdded", + "columnName": "date_added", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dateUpdated", + "columnName": "date_updated", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "imageId", + "columnName": "image_id", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "remote_id" + ], + "autoGenerate": false + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "recipe", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`remote_id` TEXT NOT NULL, `recipe_yield` TEXT NOT NULL, PRIMARY KEY(`remote_id`))", + "fields": [ + { + "fieldPath": "remoteId", + "columnName": "remote_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "recipeYield", + "columnName": "recipe_yield", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "remote_id" + ], + "autoGenerate": false + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "recipe_ingredient", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`local_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `recipe_id` TEXT NOT NULL, `note` TEXT NOT NULL)", + "fields": [ + { + "fieldPath": "localId", + "columnName": "local_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "recipeId", + "columnName": "recipe_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "note", + "columnName": "note", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "local_id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "recipe_instruction", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`local_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `recipe_id` TEXT NOT NULL, `text` TEXT NOT NULL)", + "fields": [ + { + "fieldPath": "localId", + "columnName": "local_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "recipeId", + "columnName": "recipe_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "text", + "columnName": "text", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "local_id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + } + ], + "views": [], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'e75a1e16503fdf60c62b7f9d17ec0bc6')" + ] + } +} \ No newline at end of file diff --git a/database/src/main/kotlin/gq/kirmanak/mealient/database/AppDb.kt b/database/src/main/kotlin/gq/kirmanak/mealient/database/AppDb.kt index b71d9d6..62d87f7 100644 --- a/database/src/main/kotlin/gq/kirmanak/mealient/database/AppDb.kt +++ b/database/src/main/kotlin/gq/kirmanak/mealient/database/AppDb.kt @@ -1,14 +1,12 @@ package gq.kirmanak.mealient.database -import androidx.room.AutoMigration -import androidx.room.Database -import androidx.room.RoomDatabase -import androidx.room.TypeConverters +import androidx.room.* +import androidx.room.migration.AutoMigrationSpec import gq.kirmanak.mealient.database.recipe.RecipeDao import gq.kirmanak.mealient.database.recipe.entity.* @Database( - version = 4, + version = 5, entities = [ CategoryEntity::class, CategoryRecipeEntity::class, @@ -23,9 +21,18 @@ import gq.kirmanak.mealient.database.recipe.entity.* autoMigrations = [ AutoMigration(from = 1, to = 2), AutoMigration(from = 3, to = 4), + AutoMigration(from = 4, to = 5, spec = AppDb.From4To5Migration::class), ] ) @TypeConverters(RoomTypeConverters::class) abstract class AppDb : RoomDatabase() { abstract fun recipeDao(): RecipeDao + + @DeleteColumn(tableName = "recipe_instruction", columnName = "title") + @DeleteColumn(tableName = "recipe_ingredient", columnName = "title") + @DeleteColumn(tableName = "recipe_ingredient", columnName = "unit") + @DeleteColumn(tableName = "recipe_ingredient", columnName = "food") + @DeleteColumn(tableName = "recipe_ingredient", columnName = "disable_amount") + @DeleteColumn(tableName = "recipe_ingredient", columnName = "quantity") + class From4To5Migration : AutoMigrationSpec } \ No newline at end of file diff --git a/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/entity/RecipeIngredientEntity.kt b/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/entity/RecipeIngredientEntity.kt index 8c55f5d..31b7b6a 100644 --- a/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/entity/RecipeIngredientEntity.kt +++ b/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/entity/RecipeIngredientEntity.kt @@ -8,10 +8,5 @@ import androidx.room.PrimaryKey data class RecipeIngredientEntity( @PrimaryKey(autoGenerate = true) @ColumnInfo(name = "local_id") val localId: Long = 0, @ColumnInfo(name = "recipe_id") val recipeId: String, - @ColumnInfo(name = "title") val title: String, @ColumnInfo(name = "note") val note: String, - @ColumnInfo(name = "unit") val unit: String, - @ColumnInfo(name = "food") val food: String, - @ColumnInfo(name = "disable_amount") val disableAmount: Boolean, - @ColumnInfo(name = "quantity") val quantity: Double, ) \ No newline at end of file diff --git a/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/entity/RecipeInstructionEntity.kt b/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/entity/RecipeInstructionEntity.kt index 1510b91..c5905fa 100644 --- a/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/entity/RecipeInstructionEntity.kt +++ b/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/entity/RecipeInstructionEntity.kt @@ -8,6 +8,5 @@ import androidx.room.PrimaryKey data class RecipeInstructionEntity( @PrimaryKey(autoGenerate = true) @ColumnInfo(name = "local_id") val localId: Long = 0, @ColumnInfo(name = "recipe_id") val recipeId: String, - @ColumnInfo(name = "title") val title: String, @ColumnInfo(name = "text") val text: String, ) diff --git a/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v0/models/AddRecipeRequestV0.kt b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v0/models/AddRecipeRequestV0.kt index dcec314..35f967e 100644 --- a/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v0/models/AddRecipeRequestV0.kt +++ b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v0/models/AddRecipeRequestV0.kt @@ -7,48 +7,24 @@ import kotlinx.serialization.Serializable data class AddRecipeRequestV0( @SerialName("name") val name: String = "", @SerialName("description") val description: String = "", - @SerialName("image") val image: String = "", @SerialName("recipeYield") val recipeYield: String = "", @SerialName("recipeIngredient") val recipeIngredient: List = emptyList(), @SerialName("recipeInstructions") val recipeInstructions: List = emptyList(), - @SerialName("slug") val slug: String = "", - @SerialName("filePath") val filePath: String = "", - @SerialName("tags") val tags: List = emptyList(), - @SerialName("categories") val categories: List = emptyList(), - @SerialName("notes") val notes: List = emptyList(), - @SerialName("extras") val extras: Map = emptyMap(), - @SerialName("assets") val assets: List = emptyList(), @SerialName("settings") val settings: AddRecipeSettingsV0 = AddRecipeSettingsV0(), ) @Serializable data class AddRecipeIngredientV0( - @SerialName("disableAmount") val disableAmount: Boolean = true, - @SerialName("food") val food: String? = null, @SerialName("note") val note: String = "", - @SerialName("quantity") val quantity: Int = 1, - @SerialName("title") val title: String? = null, - @SerialName("unit") val unit: String? = null, ) @Serializable data class AddRecipeInstructionV0( - @SerialName("title") val title: String = "", - @SerialName("text") val text: String = "", -) - -@Serializable -data class AddRecipeNoteV0( - @SerialName("title") val title: String = "", @SerialName("text") val text: String = "", ) @Serializable data class AddRecipeSettingsV0( - @SerialName("disableAmount") val disableAmount: Boolean = true, @SerialName("disableComments") val disableComments: Boolean = false, - @SerialName("landscapeView") val landscapeView: Boolean = true, @SerialName("public") val public: Boolean = true, - @SerialName("showAssets") val showAssets: Boolean = true, - @SerialName("showNutrition") val showNutrition: Boolean = true, ) \ No newline at end of file diff --git a/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v0/models/GetRecipeResponseV0.kt b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v0/models/GetRecipeResponseV0.kt index f940811..414badf 100644 --- a/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v0/models/GetRecipeResponseV0.kt +++ b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v0/models/GetRecipeResponseV0.kt @@ -1,7 +1,5 @@ package gq.kirmanak.mealient.datasource.v0.models -import kotlinx.datetime.LocalDate -import kotlinx.datetime.LocalDateTime import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -9,14 +7,6 @@ import kotlinx.serialization.Serializable data class GetRecipeResponseV0( @SerialName("id") val remoteId: Int, @SerialName("name") val name: String, - @SerialName("slug") val slug: String, - @SerialName("image") val image: String, - @SerialName("description") val description: String = "", - @SerialName("recipeCategory") val recipeCategories: List, - @SerialName("tags") val tags: List, - @SerialName("rating") val rating: Int?, - @SerialName("dateAdded") val dateAdded: LocalDate, - @SerialName("dateUpdated") val dateUpdated: LocalDateTime, @SerialName("recipeYield") val recipeYield: String = "", @SerialName("recipeIngredient") val recipeIngredients: List, @SerialName("recipeInstructions") val recipeInstructions: List, diff --git a/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/GetRecipeResponseV1.kt b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/GetRecipeResponseV1.kt index ce9b90f..bda326f 100644 --- a/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/GetRecipeResponseV1.kt +++ b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/GetRecipeResponseV1.kt @@ -1,7 +1,5 @@ package gq.kirmanak.mealient.datasource.v1.models -import kotlinx.datetime.LocalDate -import kotlinx.datetime.LocalDateTime import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -9,14 +7,6 @@ import kotlinx.serialization.Serializable data class GetRecipeResponseV1( @SerialName("id") val remoteId: String, @SerialName("name") val name: String, - @SerialName("slug") val slug: String, - @SerialName("image") val image: String? = null, - @SerialName("description") val description: String = "", - @SerialName("recipeCategory") val recipeCategories: List, - @SerialName("tags") val tags: List, - @SerialName("rating") val rating: Int?, - @SerialName("dateAdded") val dateAdded: LocalDate, - @SerialName("dateUpdated") val dateUpdated: LocalDateTime, @SerialName("recipeYield") val recipeYield: String = "", @SerialName("recipeIngredient") val recipeIngredients: List, @SerialName("recipeInstructions") val recipeInstructions: List, diff --git a/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/UpdateRecipeRequestV1.kt b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/UpdateRecipeRequestV1.kt index b4a8632..019bd8c 100644 --- a/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/UpdateRecipeRequestV1.kt +++ b/datasource/src/main/kotlin/gq/kirmanak/mealient/datasource/v1/models/UpdateRecipeRequestV1.kt @@ -6,48 +6,25 @@ import kotlinx.serialization.Serializable @Serializable data class UpdateRecipeRequestV1( @SerialName("description") val description: String = "", - @SerialName("image") val image: String = "", @SerialName("recipeYield") val recipeYield: String = "", @SerialName("recipeIngredient") val recipeIngredient: List = emptyList(), @SerialName("recipeInstructions") val recipeInstructions: List = emptyList(), - @SerialName("filePath") val filePath: String = "", - @SerialName("tags") val tags: List = emptyList(), - @SerialName("categories") val categories: List = emptyList(), - @SerialName("notes") val notes: List = emptyList(), - @SerialName("extras") val extras: Map = emptyMap(), - @SerialName("assets") val assets: List = emptyList(), @SerialName("settings") val settings: AddRecipeSettingsV1 = AddRecipeSettingsV1(), ) @Serializable data class AddRecipeIngredientV1( - @SerialName("disableAmount") val disableAmount: Boolean = true, - @SerialName("food") val food: String? = null, @SerialName("note") val note: String = "", - @SerialName("quantity") val quantity: Int = 1, - @SerialName("title") val title: String? = null, - @SerialName("unit") val unit: String? = null, ) @Serializable data class AddRecipeInstructionV1( - @SerialName("title") val title: String = "", @SerialName("text") val text: String = "", @SerialName("ingredientReferences") val ingredientReferences: List = emptyList(), ) -@Serializable -data class AddRecipeNoteV1( - @SerialName("title") val title: String = "", - @SerialName("text") val text: String = "", -) - @Serializable data class AddRecipeSettingsV1( - @SerialName("disableAmount") val disableAmount: Boolean = true, @SerialName("disableComments") val disableComments: Boolean = false, - @SerialName("landscapeView") val landscapeView: Boolean = true, @SerialName("public") val public: Boolean = true, - @SerialName("showAssets") val showAssets: Boolean = true, - @SerialName("showNutrition") val showNutrition: Boolean = true, ) \ No newline at end of file