mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
sort 'recent recipes' by updated
This commit is contained in:
parent
962861970d
commit
273438156e
2 changed files with 13 additions and 7 deletions
|
@ -1,5 +1,6 @@
|
||||||
import { api } from "@/api";
|
import { api } from "@/api";
|
||||||
import Vue from "vue";
|
import Vue from "vue";
|
||||||
|
import { recipe } from "@/utils/recipe";
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
recentRecipes: [],
|
recentRecipes: [],
|
||||||
|
@ -36,13 +37,14 @@ const mutations = {
|
||||||
const actions = {
|
const actions = {
|
||||||
async requestRecentRecipes() {
|
async requestRecentRecipes() {
|
||||||
const payload = await api.recipes.allSummary(0, 30);
|
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]));
|
const hash = Object.fromEntries(payload.map(e => [e.id, e]));
|
||||||
this.commit("setRecentRecipes", hash);
|
this.commit("setRecentRecipes", hash);
|
||||||
},
|
},
|
||||||
async requestAllRecipes({ getters }) {
|
async requestAllRecipes({ getters }) {
|
||||||
const all = getters.getAllRecipes;
|
const all = getters.getAllRecipes;
|
||||||
const payload = await api.recipes.allSummary(all.length, 9999);
|
const payload = await api.recipes.allSummary(all.length, 9999);
|
||||||
|
recipe.sortByUpdated(payload);
|
||||||
const hash = Object.fromEntries([...all, ...payload].map(e => [e.id, e]));
|
const hash = Object.fromEntries([...all, ...payload].map(e => [e.id, e]));
|
||||||
|
|
||||||
this.commit("setAllRecipes", hash);
|
this.commit("setAllRecipes", hash);
|
||||||
|
@ -60,7 +62,11 @@ const actions = {
|
||||||
const getters = {
|
const getters = {
|
||||||
getAllRecipes: state => Object.values(state.allRecipes),
|
getAllRecipes: state => Object.values(state.allRecipes),
|
||||||
getAllRecipesHash: state => 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,
|
getRecentRecipesHash: state => state.recentRecipes,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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])
|
@router.get("/api/recipes/summary/untagged", response_model=list[RecipeSummary])
|
||||||
async def get_untagged_recipes(session: Session = Depends(generate_session)):
|
async def get_untagged_recipes(count: bool = False, session: Session = Depends(generate_session)):
|
||||||
return db.recipes.count_untagged(session, False, override_schema=RecipeSummary)
|
return db.recipes.count_untagged(session, count=count, override_schema=RecipeSummary)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/api/recipes/summary/uncategorized", response_model=list[RecipeSummary])
|
@router.get("/api/recipes/summary/uncategorized", response_model=list[RecipeSummary])
|
||||||
async def get_uncategorized_recipes(session: Session = Depends(generate_session)):
|
async def get_uncategorized_recipes(count: bool = False, session: Session = Depends(generate_session)):
|
||||||
return db.recipes.count_uncategorized(session, False, override_schema=RecipeSummary)
|
return db.recipes.count_uncategorized(session, count=count, override_schema=RecipeSummary)
|
||||||
|
|
||||||
|
|
||||||
@router.post("/api/recipes/category")
|
@router.post("/api/recipes/category")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue