add Analyse
This commit is contained in:
@@ -31,7 +31,7 @@ export function getDb() {
|
||||
return db;
|
||||
}
|
||||
|
||||
export function getAllRecipes(search, category) {
|
||||
export function getAllRecipes(search, category, userId) {
|
||||
let results = [...db.recipes];
|
||||
|
||||
if (search) {
|
||||
@@ -47,6 +47,10 @@ export function getAllRecipes(search, category) {
|
||||
results = results.filter(r => r.category === category);
|
||||
}
|
||||
|
||||
if (userId) {
|
||||
results = results.filter(r => r.user_id === Number(userId));
|
||||
}
|
||||
|
||||
results.sort((a, b) => (b.created_at || '').localeCompare(a.created_at || ''));
|
||||
return results;
|
||||
}
|
||||
@@ -65,8 +69,11 @@ export function createRecipe(recipe) {
|
||||
ingredients: JSON.stringify(recipe.ingredients || []),
|
||||
steps: JSON.stringify(recipe.steps || []),
|
||||
category: recipe.category || 'Sonstiges',
|
||||
tiktok_url: recipe.tiktok_url || null,
|
||||
tiktok_author: recipe.tiktok_author || null,
|
||||
source: recipe.source || 'tiktok',
|
||||
source_url: recipe.source_url || recipe.tiktok_url || null,
|
||||
source_author: recipe.source_author || recipe.tiktok_author || null,
|
||||
tiktok_url: recipe.tiktok_url || recipe.source_url || null,
|
||||
tiktok_author: recipe.tiktok_author || recipe.source_author || null,
|
||||
thumbnail_url: recipe.thumbnail_url || null,
|
||||
user_id: recipe.user_id || null,
|
||||
created_at: nowStr,
|
||||
@@ -87,8 +94,11 @@ export function updateRecipe(id, recipe) {
|
||||
ingredients: JSON.stringify(recipe.ingredients || []),
|
||||
steps: JSON.stringify(recipe.steps || []),
|
||||
category: recipe.category || 'Sonstiges',
|
||||
tiktok_url: recipe.tiktok_url || null,
|
||||
tiktok_author: recipe.tiktok_author || null,
|
||||
source: recipe.source || db.recipes[idx].source || 'tiktok',
|
||||
source_url: recipe.source_url || recipe.tiktok_url || db.recipes[idx].source_url || null,
|
||||
source_author: recipe.source_author || recipe.tiktok_author || db.recipes[idx].source_author || null,
|
||||
tiktok_url: recipe.tiktok_url || recipe.source_url || db.recipes[idx].tiktok_url || null,
|
||||
tiktok_author: recipe.tiktok_author || recipe.source_author || db.recipes[idx].tiktok_author || null,
|
||||
thumbnail_url: recipe.thumbnail_url || null,
|
||||
updated_at: now(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user