Compare commits

2 Commits

Author SHA1 Message Date
397ba1efa4 add full retranslation button to recipe edit page
All checks were successful
CI / update (push) Successful in 1m10s
Adds a button to force complete retranslation of existing recipes, bypassing the changed-field detection to retranslate all fields from scratch.
2026-01-02 17:36:58 +01:00
1a943cebcf fix: filter English API endpoints to only return approved translations
Previously, all English recipe API endpoints were returning any recipe with
a translations.en object, regardless of approval status. This caused 218
recipes to appear instead of only approved ones.

Updated all 9 English API endpoints to filter for translationStatus='approved':
- /api/recipes/items/all_brief
- /api/recipes/items/in_season/[month]
- /api/recipes/items/category and /api/recipes/items/category/[category]
- /api/recipes/items/tag and /api/recipes/items/tag/[tag]
- /api/recipes/items/icon/[icon]
- /api/recipes/search
- /api/recipes/favorites/recipes
2026-01-02 17:36:44 +01:00
10 changed files with 33 additions and 18 deletions

View File

@@ -156,6 +156,18 @@
}, 100);
}
// Force full retranslation of entire recipe
function forceFullRetranslation() {
// Set changedFields to empty array to trigger full translation
changedFields = [];
showTranslationWorkflow = true;
// Scroll to translation section
setTimeout(() => {
document.getElementById('translation-section')?.scrollIntoView({ behavior: 'smooth' });
}, 100);
}
// Handle translation approval
function handleTranslationApproved(event: CustomEvent) {
translationData = event.detail.translatedRecipe;
@@ -473,6 +485,9 @@ button.action_button{
{#if !showTranslationWorkflow}
<div class=submit_buttons>
<button class=action_button on:click={doDelete}><p>Löschen</p><Cross fill=white width=2rem height=2rem></Cross></button>
{#if translationData}
<button class=action_button style="background-color: var(--nord13);" on:click={forceFullRetranslation}><p>Vollständig neu übersetzen</p><Check fill=white width=2rem height=2rem></Check></button>
{/if}
<button class=action_button on:click={prepareSubmit}><p>Weiter zur Übersetzung</p><Check fill=white width=2rem height=2rem></Check></button>
</div>
{/if}

View File

@@ -23,10 +23,10 @@ export const GET: RequestHandler = async ({ locals }) => {
return json([]);
}
// Get recipes that are favorited AND have English translations
// Get recipes that are favorited AND have approved English translations
let recipes = await Recipe.find({
_id: { $in: userFavorites.favorites },
'translations.en': { $exists: true }
'translations.en.translationStatus': 'approved'
}).lean();
// Transform to English format

View File

@@ -7,9 +7,9 @@ import { rand_array } from '$lib/js/randomize';
export const GET: RequestHandler = async ({params}) => {
await dbConnect();
// Find all recipes that have English translations
// Find all recipes that have approved English translations
const recipes = await Recipe.find(
{ 'translations.en': { $exists: true } },
{ 'translations.en.translationStatus': 'approved' },
'_id translations.en short_name season dateModified icon'
).lean();

View File

@@ -5,9 +5,9 @@ import { dbConnect } from '../../../../../utils/db';
export const GET: RequestHandler = async ({params}) => {
await dbConnect();
// Get distinct categories from English translations
// Get distinct categories from approved English translations
const categories = await Recipe.distinct('translations.en.category', {
'translations.en': { $exists: true }
'translations.en.translationStatus': 'approved'
}).lean();
return json(JSON.parse(JSON.stringify(categories)));

View File

@@ -7,11 +7,11 @@ import { rand_array } from '$lib/js/randomize';
export const GET: RequestHandler = async ({params}) => {
await dbConnect();
// Find recipes in this category that have English translations
// Find recipes in this category that have approved English translations
const recipes = await Recipe.find(
{
'translations.en.category': params.category,
'translations.en': { $exists: true }
'translations.en.translationStatus': 'approved'
},
'_id translations.en short_name images season dateModified icon'
).lean();

View File

@@ -7,11 +7,11 @@ import { rand_array } from '$lib/js/randomize';
export const GET: RequestHandler = async ({params}) => {
await dbConnect();
// Find recipes with this icon that have English translations
// Find recipes with this icon that have approved English translations
const recipes = await Recipe.find(
{
icon: params.icon,
'translations.en': { $exists: true }
'translations.en.translationStatus': 'approved'
},
'_id translations.en short_name images season dateModified icon'
).lean();

View File

@@ -6,12 +6,12 @@ import { rand_array } from '$lib/js/randomize';
export const GET: RequestHandler = async ({params}) => {
await dbConnect();
// Find recipes in season that have English translations
// Find recipes in season that have approved English translations
const recipes = await Recipe.find(
{
season: params.month,
icon: {$ne: "🍽️"},
'translations.en': { $exists: true }
'translations.en.translationStatus': 'approved'
},
'_id translations.en short_name images season dateModified icon'
).lean();

View File

@@ -5,9 +5,9 @@ import { dbConnect } from '../../../../../utils/db';
export const GET: RequestHandler = async ({params}) => {
await dbConnect();
// Get all recipes with English translations
// Get all recipes with approved English translations
const recipes = await Recipe.find({
'translations.en': { $exists: true }
'translations.en.translationStatus': 'approved'
}, 'translations.en.tags').lean();
// Extract and flatten all unique tags

View File

@@ -7,11 +7,11 @@ import { rand_array } from '$lib/js/randomize';
export const GET: RequestHandler = async ({params}) => {
await dbConnect();
// Find recipes with this tag that have English translations
// Find recipes with this tag that have approved English translations
const recipes = await Recipe.find(
{
'translations.en.tags': params.tag,
'translations.en': { $exists: true }
'translations.en.translationStatus': 'approved'
},
'_id translations.en short_name images season dateModified icon'
).lean();

View File

@@ -14,9 +14,9 @@ export const GET: RequestHandler = async ({ url, locals }) => {
const favoritesOnly = url.searchParams.get('favorites') === 'true';
try {
// Build base query - only recipes with English translations
// Build base query - only recipes with approved English translations
let dbQuery: any = {
'translations.en': { $exists: true }
'translations.en.translationStatus': 'approved'
};
// Apply filters based on context