Fix absent images on v0.5.6
This commit is contained in:
@@ -6,13 +6,14 @@ import gq.kirmanak.mealient.data.baseurl.BaseURLStorage
|
|||||||
import gq.kirmanak.mealient.data.baseurl.VersionDataSource
|
import gq.kirmanak.mealient.data.baseurl.VersionDataSource
|
||||||
import gq.kirmanak.mealient.data.baseurl.VersionInfo
|
import gq.kirmanak.mealient.data.baseurl.VersionInfo
|
||||||
import gq.kirmanak.mealient.data.recipes.network.RecipeDataSource
|
import gq.kirmanak.mealient.data.recipes.network.RecipeDataSource
|
||||||
|
import gq.kirmanak.mealient.data.recipes.network.RecipeSummaryInfo
|
||||||
import gq.kirmanak.mealient.datasource.MealieDataSource
|
import gq.kirmanak.mealient.datasource.MealieDataSource
|
||||||
import gq.kirmanak.mealient.datasource.models.AddRecipeRequest
|
import gq.kirmanak.mealient.datasource.models.AddRecipeRequest
|
||||||
import gq.kirmanak.mealient.datasource.models.GetRecipeResponse
|
import gq.kirmanak.mealient.datasource.models.GetRecipeResponse
|
||||||
import gq.kirmanak.mealient.datasource.models.NetworkError
|
import gq.kirmanak.mealient.datasource.models.NetworkError
|
||||||
import gq.kirmanak.mealient.datasource.v1.MealieDataSourceV1
|
import gq.kirmanak.mealient.datasource.v1.MealieDataSourceV1
|
||||||
import gq.kirmanak.mealient.datasource.v1.models.GetRecipeSummaryResponseV1
|
|
||||||
import gq.kirmanak.mealient.extensions.runCatchingExceptCancel
|
import gq.kirmanak.mealient.extensions.runCatchingExceptCancel
|
||||||
|
import gq.kirmanak.mealient.extensions.toRecipeSummaryInfo
|
||||||
import gq.kirmanak.mealient.extensions.toVersionInfo
|
import gq.kirmanak.mealient.extensions.toVersionInfo
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
@@ -21,48 +22,36 @@ import javax.inject.Singleton
|
|||||||
class MealieDataSourceWrapper @Inject constructor(
|
class MealieDataSourceWrapper @Inject constructor(
|
||||||
private val baseURLStorage: BaseURLStorage,
|
private val baseURLStorage: BaseURLStorage,
|
||||||
private val authRepo: AuthRepo,
|
private val authRepo: AuthRepo,
|
||||||
private val mealieDataSource: MealieDataSource,
|
private val source: MealieDataSource,
|
||||||
private val mealieDataSourceV1: MealieDataSourceV1,
|
private val v1Source: MealieDataSourceV1,
|
||||||
) : AddRecipeDataSource, RecipeDataSource, VersionDataSource {
|
) : AddRecipeDataSource, RecipeDataSource, VersionDataSource {
|
||||||
|
|
||||||
override suspend fun addRecipe(recipe: AddRecipeRequest): String =
|
override suspend fun addRecipe(recipe: AddRecipeRequest): String =
|
||||||
withAuthHeader { token -> mealieDataSource.addRecipe(getUrl(), token, recipe) }
|
withAuthHeader { token -> source.addRecipe(getUrl(), token, recipe) }
|
||||||
|
|
||||||
override suspend fun getVersionInfo(baseUrl: String): VersionInfo =
|
override suspend fun getVersionInfo(baseUrl: String): VersionInfo =
|
||||||
runCatchingExceptCancel {
|
runCatchingExceptCancel {
|
||||||
mealieDataSource.getVersionInfo(baseUrl).toVersionInfo()
|
source.getVersionInfo(baseUrl).toVersionInfo()
|
||||||
}.getOrElse {
|
}.getOrElse {
|
||||||
if (it is NetworkError.NotMealie) {
|
if (it is NetworkError.NotMealie) {
|
||||||
mealieDataSourceV1.getVersionInfo(baseUrl).toVersionInfo()
|
v1Source.getVersionInfo(baseUrl).toVersionInfo()
|
||||||
} else {
|
} else {
|
||||||
throw it
|
throw it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun requestRecipes(start: Int, limit: Int): List<GetRecipeSummaryResponseV1> =
|
override suspend fun requestRecipes(start: Int, limit: Int): List<RecipeSummaryInfo> =
|
||||||
withAuthHeader { token ->
|
withAuthHeader { token ->
|
||||||
|
val url = getUrl()
|
||||||
if (isV1()) {
|
if (isV1()) {
|
||||||
mealieDataSourceV1.requestRecipes(getUrl(), token, start, limit)
|
v1Source.requestRecipes(url, token, start, limit).map { it.toRecipeSummaryInfo() }
|
||||||
} else {
|
} else {
|
||||||
mealieDataSource.requestRecipes(getUrl(), token, start, limit).map {
|
source.requestRecipes(url, token, start, limit).map { it.toRecipeSummaryInfo() }
|
||||||
GetRecipeSummaryResponseV1(
|
|
||||||
remoteId = it.remoteId.toString(),
|
|
||||||
name = it.name,
|
|
||||||
slug = it.slug,
|
|
||||||
image = it.image,
|
|
||||||
description = it.description,
|
|
||||||
recipeCategories = it.recipeCategories,
|
|
||||||
tags = it.tags,
|
|
||||||
rating = it.rating,
|
|
||||||
dateAdded = it.dateAdded,
|
|
||||||
dateUpdated = it.dateUpdated,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun requestRecipeInfo(slug: String): GetRecipeResponse =
|
override suspend fun requestRecipeInfo(slug: String): GetRecipeResponse =
|
||||||
withAuthHeader { token -> mealieDataSource.requestRecipeInfo(getUrl(), token, slug) }
|
withAuthHeader { token -> source.requestRecipeInfo(getUrl(), token, slug) }
|
||||||
|
|
||||||
private suspend fun getUrl() = baseURLStorage.requireBaseURL()
|
private suspend fun getUrl() = baseURLStorage.requireBaseURL()
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
package gq.kirmanak.mealient.data.recipes.db
|
package gq.kirmanak.mealient.data.recipes.db
|
||||||
|
|
||||||
import androidx.paging.PagingSource
|
import androidx.paging.PagingSource
|
||||||
|
import gq.kirmanak.mealient.data.recipes.network.RecipeSummaryInfo
|
||||||
import gq.kirmanak.mealient.database.recipe.entity.FullRecipeInfo
|
import gq.kirmanak.mealient.database.recipe.entity.FullRecipeInfo
|
||||||
import gq.kirmanak.mealient.database.recipe.entity.RecipeSummaryEntity
|
import gq.kirmanak.mealient.database.recipe.entity.RecipeSummaryEntity
|
||||||
import gq.kirmanak.mealient.datasource.models.GetRecipeResponse
|
import gq.kirmanak.mealient.datasource.models.GetRecipeResponse
|
||||||
import gq.kirmanak.mealient.datasource.v1.models.GetRecipeSummaryResponseV1
|
|
||||||
|
|
||||||
interface RecipeStorage {
|
interface RecipeStorage {
|
||||||
suspend fun saveRecipes(recipes: List<GetRecipeSummaryResponseV1>)
|
suspend fun saveRecipes(recipes: List<RecipeSummaryInfo>)
|
||||||
|
|
||||||
fun queryRecipes(): PagingSource<Int, RecipeSummaryEntity>
|
fun queryRecipes(): PagingSource<Int, RecipeSummaryEntity>
|
||||||
|
|
||||||
suspend fun refreshAll(recipes: List<GetRecipeSummaryResponseV1>)
|
suspend fun refreshAll(recipes: List<RecipeSummaryInfo>)
|
||||||
|
|
||||||
suspend fun clearAllLocalData()
|
suspend fun clearAllLocalData()
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ package gq.kirmanak.mealient.data.recipes.db
|
|||||||
|
|
||||||
import androidx.paging.PagingSource
|
import androidx.paging.PagingSource
|
||||||
import androidx.room.withTransaction
|
import androidx.room.withTransaction
|
||||||
|
import gq.kirmanak.mealient.data.recipes.network.RecipeSummaryInfo
|
||||||
import gq.kirmanak.mealient.database.AppDb
|
import gq.kirmanak.mealient.database.AppDb
|
||||||
import gq.kirmanak.mealient.database.recipe.RecipeDao
|
import gq.kirmanak.mealient.database.recipe.RecipeDao
|
||||||
import gq.kirmanak.mealient.database.recipe.entity.*
|
import gq.kirmanak.mealient.database.recipe.entity.*
|
||||||
import gq.kirmanak.mealient.datasource.models.GetRecipeResponse
|
import gq.kirmanak.mealient.datasource.models.GetRecipeResponse
|
||||||
import gq.kirmanak.mealient.datasource.v1.models.GetRecipeSummaryResponseV1
|
|
||||||
import gq.kirmanak.mealient.extensions.recipeEntity
|
import gq.kirmanak.mealient.extensions.recipeEntity
|
||||||
import gq.kirmanak.mealient.extensions.toRecipeEntity
|
import gq.kirmanak.mealient.extensions.toRecipeEntity
|
||||||
import gq.kirmanak.mealient.extensions.toRecipeIngredientEntity
|
import gq.kirmanak.mealient.extensions.toRecipeIngredientEntity
|
||||||
@@ -23,7 +23,7 @@ class RecipeStorageImpl @Inject constructor(
|
|||||||
private val recipeDao: RecipeDao by lazy { db.recipeDao() }
|
private val recipeDao: RecipeDao by lazy { db.recipeDao() }
|
||||||
|
|
||||||
override suspend fun saveRecipes(
|
override suspend fun saveRecipes(
|
||||||
recipes: List<GetRecipeSummaryResponseV1>
|
recipes: List<RecipeSummaryInfo>
|
||||||
) = db.withTransaction {
|
) = db.withTransaction {
|
||||||
logger.v { "saveRecipes() called with $recipes" }
|
logger.v { "saveRecipes() called with $recipes" }
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ class RecipeStorageImpl @Inject constructor(
|
|||||||
return recipeDao.queryRecipesByPages()
|
return recipeDao.queryRecipesByPages()
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun refreshAll(recipes: List<GetRecipeSummaryResponseV1>) {
|
override suspend fun refreshAll(recipes: List<RecipeSummaryInfo>) {
|
||||||
logger.v { "refreshAll() called with: recipes = $recipes" }
|
logger.v { "refreshAll() called with: recipes = $recipes" }
|
||||||
db.withTransaction {
|
db.withTransaction {
|
||||||
recipeDao.removeAllRecipes()
|
recipeDao.removeAllRecipes()
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
package gq.kirmanak.mealient.data.recipes.network
|
package gq.kirmanak.mealient.data.recipes.network
|
||||||
|
|
||||||
import gq.kirmanak.mealient.datasource.models.GetRecipeResponse
|
import gq.kirmanak.mealient.datasource.models.GetRecipeResponse
|
||||||
import gq.kirmanak.mealient.datasource.v1.models.GetRecipeSummaryResponseV1
|
|
||||||
|
|
||||||
interface RecipeDataSource {
|
interface RecipeDataSource {
|
||||||
suspend fun requestRecipes(start: Int, limit: Int): List<GetRecipeSummaryResponseV1>
|
suspend fun requestRecipes(start: Int, limit: Int): List<RecipeSummaryInfo>
|
||||||
|
|
||||||
suspend fun requestRecipeInfo(slug: String): GetRecipeResponse
|
suspend fun requestRecipeInfo(slug: String): GetRecipeResponse
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package gq.kirmanak.mealient.data.recipes.network
|
||||||
|
|
||||||
|
import kotlinx.datetime.LocalDate
|
||||||
|
import kotlinx.datetime.LocalDateTime
|
||||||
|
|
||||||
|
data class RecipeSummaryInfo(
|
||||||
|
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 imageId: String,
|
||||||
|
)
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package gq.kirmanak.mealient.extensions
|
package gq.kirmanak.mealient.extensions
|
||||||
|
|
||||||
import gq.kirmanak.mealient.data.baseurl.VersionInfo
|
import gq.kirmanak.mealient.data.baseurl.VersionInfo
|
||||||
|
import gq.kirmanak.mealient.data.recipes.network.RecipeSummaryInfo
|
||||||
import gq.kirmanak.mealient.database.recipe.entity.RecipeEntity
|
import gq.kirmanak.mealient.database.recipe.entity.RecipeEntity
|
||||||
import gq.kirmanak.mealient.database.recipe.entity.RecipeIngredientEntity
|
import gq.kirmanak.mealient.database.recipe.entity.RecipeIngredientEntity
|
||||||
import gq.kirmanak.mealient.database.recipe.entity.RecipeInstructionEntity
|
import gq.kirmanak.mealient.database.recipe.entity.RecipeInstructionEntity
|
||||||
@@ -33,7 +34,35 @@ fun GetRecipeInstructionResponse.toRecipeInstructionEntity(remoteId: String) =
|
|||||||
text = text
|
text = text
|
||||||
)
|
)
|
||||||
|
|
||||||
fun GetRecipeSummaryResponseV1.recipeEntity() = RecipeSummaryEntity(
|
fun GetRecipeSummaryResponse.toRecipeSummaryInfo() = RecipeSummaryInfo(
|
||||||
|
remoteId = remoteId.toString(),
|
||||||
|
name = name,
|
||||||
|
slug = slug,
|
||||||
|
image = image,
|
||||||
|
description = description,
|
||||||
|
recipeCategories = recipeCategories,
|
||||||
|
tags = tags,
|
||||||
|
rating = rating,
|
||||||
|
dateAdded = dateAdded,
|
||||||
|
dateUpdated = dateUpdated,
|
||||||
|
imageId = slug,
|
||||||
|
)
|
||||||
|
|
||||||
|
fun GetRecipeSummaryResponseV1.toRecipeSummaryInfo() = RecipeSummaryInfo(
|
||||||
|
remoteId = remoteId,
|
||||||
|
name = name,
|
||||||
|
slug = slug,
|
||||||
|
image = image,
|
||||||
|
description = description,
|
||||||
|
recipeCategories = recipeCategories,
|
||||||
|
tags = tags,
|
||||||
|
rating = rating,
|
||||||
|
dateAdded = dateAdded,
|
||||||
|
dateUpdated = dateUpdated,
|
||||||
|
imageId = remoteId,
|
||||||
|
)
|
||||||
|
|
||||||
|
fun RecipeSummaryInfo.recipeEntity() = RecipeSummaryEntity(
|
||||||
remoteId = remoteId,
|
remoteId = remoteId,
|
||||||
name = name,
|
name = name,
|
||||||
slug = slug,
|
slug = slug,
|
||||||
@@ -42,6 +71,7 @@ fun GetRecipeSummaryResponseV1.recipeEntity() = RecipeSummaryEntity(
|
|||||||
rating = rating,
|
rating = rating,
|
||||||
dateAdded = dateAdded,
|
dateAdded = dateAdded,
|
||||||
dateUpdated = dateUpdated,
|
dateUpdated = dateUpdated,
|
||||||
|
imageId = imageId,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun VersionResponse.toVersionInfo() = VersionInfo(version)
|
fun VersionResponse.toVersionInfo() = VersionInfo(version)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class RecipeModelLoader private constructor(
|
|||||||
options: Options?
|
options: Options?
|
||||||
): String? {
|
): String? {
|
||||||
logger.v { "getUrl() called with: model = $model, width = $width, height = $height, options = $options" }
|
logger.v { "getUrl() called with: model = $model, width = $width, height = $height, options = $options" }
|
||||||
return runBlocking { recipeImageUrlProvider.generateImageUrl(model?.remoteId) }
|
return runBlocking { recipeImageUrlProvider.generateImageUrl(model?.imageId) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getHeaders(
|
override fun getHeaders(
|
||||||
|
|||||||
410
database/schemas/gq.kirmanak.mealient.database.AppDb/4.json
Normal file
410
database/schemas/gq.kirmanak.mealient.database.AppDb/4.json
Normal file
@@ -0,0 +1,410 @@
|
|||||||
|
{
|
||||||
|
"formatVersion": 1,
|
||||||
|
"database": {
|
||||||
|
"version": 4,
|
||||||
|
"identityHash": "13be83018f147e1f6e864790656da4a7",
|
||||||
|
"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, `title` TEXT NOT NULL, `note` TEXT NOT NULL, `unit` TEXT NOT NULL, `food` TEXT NOT NULL, `disable_amount` INTEGER NOT NULL, `quantity` REAL NOT NULL)",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "localId",
|
||||||
|
"columnName": "local_id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "recipeId",
|
||||||
|
"columnName": "recipe_id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "title",
|
||||||
|
"columnName": "title",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "note",
|
||||||
|
"columnName": "note",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "unit",
|
||||||
|
"columnName": "unit",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "food",
|
||||||
|
"columnName": "food",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "disableAmount",
|
||||||
|
"columnName": "disable_amount",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "quantity",
|
||||||
|
"columnName": "quantity",
|
||||||
|
"affinity": "REAL",
|
||||||
|
"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, `title` 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": "title",
|
||||||
|
"columnName": "title",
|
||||||
|
"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, '13be83018f147e1f6e864790656da4a7')"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ import gq.kirmanak.mealient.database.recipe.RecipeDao
|
|||||||
import gq.kirmanak.mealient.database.recipe.entity.*
|
import gq.kirmanak.mealient.database.recipe.entity.*
|
||||||
|
|
||||||
@Database(
|
@Database(
|
||||||
version = 3,
|
version = 4,
|
||||||
entities = [
|
entities = [
|
||||||
CategoryEntity::class,
|
CategoryEntity::class,
|
||||||
CategoryRecipeEntity::class,
|
CategoryRecipeEntity::class,
|
||||||
@@ -22,6 +22,7 @@ import gq.kirmanak.mealient.database.recipe.entity.*
|
|||||||
exportSchema = true,
|
exportSchema = true,
|
||||||
autoMigrations = [
|
autoMigrations = [
|
||||||
AutoMigration(from = 1, to = 2),
|
AutoMigration(from = 1, to = 2),
|
||||||
|
AutoMigration(from = 3, to = 4),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@TypeConverters(RoomTypeConverters::class)
|
@TypeConverters(RoomTypeConverters::class)
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ data class RecipeSummaryEntity(
|
|||||||
@ColumnInfo(name = "description") val description: String,
|
@ColumnInfo(name = "description") val description: String,
|
||||||
@ColumnInfo(name = "rating") val rating: Int?,
|
@ColumnInfo(name = "rating") val rating: Int?,
|
||||||
@ColumnInfo(name = "date_added") val dateAdded: LocalDate,
|
@ColumnInfo(name = "date_added") val dateAdded: LocalDate,
|
||||||
@ColumnInfo(name = "date_updated") val dateUpdated: LocalDateTime
|
@ColumnInfo(name = "date_updated") val dateUpdated: LocalDateTime,
|
||||||
|
@ColumnInfo(name = "image_id") val imageId: String?,
|
||||||
) {
|
) {
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "RecipeSummaryEntity(remoteId=$remoteId, name='$name')"
|
return "RecipeSummaryEntity(remoteId=$remoteId, name='$name')"
|
||||||
|
|||||||
Reference in New Issue
Block a user