diff --git a/frontend/src/store/modules/recipes.js b/frontend/src/store/modules/recipes.js index 887acb49d..0b098337c 100644 --- a/frontend/src/store/modules/recipes.js +++ b/frontend/src/store/modules/recipes.js @@ -1,5 +1,6 @@ import { api } from "@/api"; import Vue from "vue"; +import { recipe } from "@/utils/recipe"; const state = { recentRecipes: [], @@ -36,13 +37,14 @@ const mutations = { const actions = { async requestRecentRecipes() { const payload = await api.recipes.allSummary(0, 30); - payload.sort((a, b) => (a.dateAdded > b.dateAdded ? -1 : 1)); + recipe.sortByUpdated(payload); const hash = Object.fromEntries(payload.map(e => [e.id, e])); this.commit("setRecentRecipes", hash); }, async requestAllRecipes({ getters }) { const all = getters.getAllRecipes; const payload = await api.recipes.allSummary(all.length, 9999); + recipe.sortByUpdated(payload); const hash = Object.fromEntries([...all, ...payload].map(e => [e.id, e])); this.commit("setAllRecipes", hash); @@ -60,7 +62,11 @@ const actions = { const getters = { getAllRecipes: state => Object.values(state.allRecipes), getAllRecipesHash: state => state.allRecipes, - getRecentRecipes: state => Object.values(state.recentRecipes), + getRecentRecipes: state => { + let list = Object.values(state.recentRecipes); + recipe.sortByUpdated(list); + return list; + }, getRecentRecipesHash: state => state.recentRecipes, }; diff --git a/mealie/routes/recipe/all_recipe_routes.py b/mealie/routes/recipe/all_recipe_routes.py index 9a61751c9..e75de92a8 100644 --- a/mealie/routes/recipe/all_recipe_routes.py +++ b/mealie/routes/recipe/all_recipe_routes.py @@ -26,17 +26,17 @@ async def get_recipe_summary( """ - return db.recipes.get_all(session, limit=limit, start=start, override_schema=RecipeSummary) + return db.recipes.get_all(session, limit=limit, start=start, order_by="date_updated", override_schema=RecipeSummary) @router.get("/api/recipes/summary/untagged", response_model=list[RecipeSummary]) -async def get_untagged_recipes(session: Session = Depends(generate_session)): - return db.recipes.count_untagged(session, False, override_schema=RecipeSummary) +async def get_untagged_recipes(count: bool = False, session: Session = Depends(generate_session)): + return db.recipes.count_untagged(session, count=count, override_schema=RecipeSummary) @router.get("/api/recipes/summary/uncategorized", response_model=list[RecipeSummary]) -async def get_uncategorized_recipes(session: Session = Depends(generate_session)): - return db.recipes.count_uncategorized(session, False, override_schema=RecipeSummary) +async def get_uncategorized_recipes(count: bool = False, session: Session = Depends(generate_session)): + return db.recipes.count_uncategorized(session, count=count, override_schema=RecipeSummary) @router.post("/api/recipes/category")