fix: add defensive fallbacks for missing database relationships
This commit is contained in:
@@ -21,10 +21,13 @@ COPY . .
|
|||||||
# Wir müssen die Variablen als Build-Argumente definieren
|
# Wir müssen die Variablen als Build-Argumente definieren
|
||||||
ARG NEXT_PUBLIC_SUPABASE_URL
|
ARG NEXT_PUBLIC_SUPABASE_URL
|
||||||
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
|
ARG NEXT_PUBLIC_SUPABASE_ANON_KEY
|
||||||
|
ARG GEMINI_API_KEY
|
||||||
|
|
||||||
# Und sie als Environment-Variablen für den Build-Prozess setzen
|
# Und sie als Environment-Variablen für den Build-Prozess setzen
|
||||||
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL
|
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL
|
||||||
ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY
|
ENV NEXT_PUBLIC_SUPABASE_ANON_KEY=$NEXT_PUBLIC_SUPABASE_ANON_KEY
|
||||||
|
ENV GEMINI_API_KEY=$GEMINI_API_KEY
|
||||||
|
|
||||||
# --- NEU HINZUFÜGEN: ENDE ---
|
# --- NEU HINZUFÜGEN: ENDE ---
|
||||||
|
|
||||||
ENV NEXT_TELEMETRY_DISABLED 1
|
ENV NEXT_TELEMETRY_DISABLED 1
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export default async function BottlePage({
|
|||||||
notFound();
|
notFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data: tastings } = await supabase
|
const tastingsResult = await supabase
|
||||||
.from('tastings')
|
.from('tastings')
|
||||||
.select(`
|
.select(`
|
||||||
*,
|
*,
|
||||||
@@ -57,6 +57,28 @@ export default async function BottlePage({
|
|||||||
.eq('bottle_id', params.id)
|
.eq('bottle_id', params.id)
|
||||||
.order('created_at', { ascending: false });
|
.order('created_at', { ascending: false });
|
||||||
|
|
||||||
|
let tastings = tastingsResult.data;
|
||||||
|
|
||||||
|
if (tastingsResult.error) {
|
||||||
|
console.error('Error fetching tastings with sessions:', tastingsResult.error);
|
||||||
|
// Fallback: try without session join if relationship is missing
|
||||||
|
const fallbackResult = await supabase
|
||||||
|
.from('tastings')
|
||||||
|
.select(`
|
||||||
|
*,
|
||||||
|
tasting_tags (
|
||||||
|
buddies (
|
||||||
|
id,
|
||||||
|
name
|
||||||
|
)
|
||||||
|
)
|
||||||
|
`)
|
||||||
|
.eq('bottle_id', params.id)
|
||||||
|
.order('created_at', { ascending: false });
|
||||||
|
|
||||||
|
tastings = fallbackResult.data;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="min-h-screen bg-zinc-50 dark:bg-black p-4 md:p-12 lg:p-24">
|
<main className="min-h-screen bg-zinc-50 dark:bg-black p-4 md:p-12 lg:p-24">
|
||||||
<div className="max-w-4xl mx-auto space-y-6 md:space-y-12">
|
<div className="max-w-4xl mx-auto space-y-6 md:space-y-12">
|
||||||
|
|||||||
@@ -40,6 +40,24 @@ export default function SessionList() {
|
|||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('Error fetching sessions:', error);
|
console.error('Error fetching sessions:', error);
|
||||||
|
// Fallback: try without tastings join if relationship is missing
|
||||||
|
const { data: fallbackData, error: fallbackError } = await supabase
|
||||||
|
.from('tasting_sessions')
|
||||||
|
.select(`
|
||||||
|
*,
|
||||||
|
session_participants (count)
|
||||||
|
`)
|
||||||
|
.order('scheduled_at', { ascending: false });
|
||||||
|
|
||||||
|
if (fallbackError) {
|
||||||
|
console.error('Error fetching sessions fallback:', fallbackError);
|
||||||
|
} else {
|
||||||
|
setSessions(fallbackData.map(s => ({
|
||||||
|
...s,
|
||||||
|
participant_count: s.session_participants[0]?.count || 0,
|
||||||
|
whisky_count: 0
|
||||||
|
})) || []);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
setSessions(data.map(s => ({
|
setSessions(data.map(s => ({
|
||||||
...s,
|
...s,
|
||||||
|
|||||||
Reference in New Issue
Block a user