mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-09 03:04:54 -04:00
feat: keep original text on ingredient parse (#1102)
* Keep Original Text on Ingredient Parse * Reorder migration and update test
This commit is contained in:
parent
5e44d1c238
commit
6f309d7a89
@ -0,0 +1,24 @@
|
|||||||
|
"""Add original_text column to recipes_ingredients
|
||||||
|
|
||||||
|
Revision ID: f1a2dbee5fe9
|
||||||
|
Revises: 263dd6707191
|
||||||
|
Create Date: 2022-03-27 19:30:28.545846
|
||||||
|
|
||||||
|
"""
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = "f1a2dbee5fe9"
|
||||||
|
down_revision = "263dd6707191"
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
op.add_column("recipes_ingredients", sa.Column("original_text", sa.String(), nullable=True))
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
op.drop_column("recipes_ingredients", "original_text")
|
@ -23,6 +23,7 @@ export interface Ingredient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ParsedIngredient {
|
export interface ParsedIngredient {
|
||||||
|
input: string
|
||||||
confidence: Confidence;
|
confidence: Confidence;
|
||||||
ingredient: Ingredient;
|
ingredient: Ingredient;
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,7 @@ import { CreateIngredientFood, CreateIngredientUnit, IngredientFood, IngredientU
|
|||||||
import RecipeIngredientEditor from "~/components/Domain/Recipe/RecipeIngredientEditor.vue";
|
import RecipeIngredientEditor from "~/components/Domain/Recipe/RecipeIngredientEditor.vue";
|
||||||
import { useUserApi } from "~/composables/api";
|
import { useUserApi } from "~/composables/api";
|
||||||
import { useFoods, useRecipe, useUnits } from "~/composables/recipes";
|
import { useFoods, useRecipe, useUnits } from "~/composables/recipes";
|
||||||
|
import { RecipeIngredient } from "~/types/api-types/admin";
|
||||||
|
|
||||||
interface Error {
|
interface Error {
|
||||||
ingredientIndex: number;
|
ingredientIndex: number;
|
||||||
@ -218,7 +219,8 @@ export default defineComponent({
|
|||||||
let ingredients = parsedIng.value.map((ing) => {
|
let ingredients = parsedIng.value.map((ing) => {
|
||||||
return {
|
return {
|
||||||
...ing.ingredient,
|
...ing.ingredient,
|
||||||
};
|
originalText: ing.input
|
||||||
|
} as RecipeIngredient;
|
||||||
});
|
});
|
||||||
|
|
||||||
ingredients = ingredients.map((ing) => {
|
ingredients = ingredients.map((ing) => {
|
||||||
|
@ -155,6 +155,7 @@ export interface RecipeIngredient {
|
|||||||
food?: IngredientFood | CreateIngredientFood;
|
food?: IngredientFood | CreateIngredientFood;
|
||||||
disableAmount?: boolean;
|
disableAmount?: boolean;
|
||||||
quantity?: number;
|
quantity?: number;
|
||||||
|
originalText?: string;
|
||||||
referenceId?: string;
|
referenceId?: string;
|
||||||
}
|
}
|
||||||
export interface Recipe {
|
export interface Recipe {
|
||||||
|
@ -63,6 +63,8 @@ class RecipeIngredient(SqlAlchemyBase, BaseMixins):
|
|||||||
food = orm.relationship(IngredientFoodModel, uselist=False)
|
food = orm.relationship(IngredientFoodModel, uselist=False)
|
||||||
quantity = Column(Float)
|
quantity = Column(Float)
|
||||||
|
|
||||||
|
original_text = Column(String)
|
||||||
|
|
||||||
reference_id = Column(GUID) # Reference Links
|
reference_id = Column(GUID) # Reference Links
|
||||||
|
|
||||||
@auto_init()
|
@auto_init()
|
||||||
|
@ -54,6 +54,7 @@ class RecipeIngredient(MealieModel):
|
|||||||
food: Optional[Union[IngredientFood, CreateIngredientFood]]
|
food: Optional[Union[IngredientFood, CreateIngredientFood]]
|
||||||
disable_amount: bool = True
|
disable_amount: bool = True
|
||||||
quantity: float = 1
|
quantity: float = 1
|
||||||
|
original_text: Optional[str]
|
||||||
|
|
||||||
# Ref is used as a way to distinguish between an individual ingredient on the frontend
|
# Ref is used as a way to distinguish between an individual ingredient on the frontend
|
||||||
# It is required for the reorder and section titles to function properly because of how
|
# It is required for the reorder and section titles to function properly because of how
|
||||||
|
@ -4,7 +4,7 @@ from mealie.core.config import get_app_settings
|
|||||||
from mealie.services.backups_v2.alchemy_exporter import AlchemyExporter
|
from mealie.services.backups_v2.alchemy_exporter import AlchemyExporter
|
||||||
|
|
||||||
ALEMBIC_VERSIONS = [
|
ALEMBIC_VERSIONS = [
|
||||||
{"version_num": "263dd6707191"},
|
{"version_num": "f1a2dbee5fe9"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user