Refactor log_request_metadata function

This commit is contained in:
gpt-engineer-app[bot]
2025-11-03 20:58:52 +00:00
parent 50e560f7cd
commit 19b1451f32
11 changed files with 992 additions and 63 deletions

View File

@@ -23,22 +23,31 @@ export function RecentPhotosPreview({ rideId, onViewAll }: RecentPhotosPreviewPr
async function fetchPhotos() {
const { data, error } = await supabase
.from('reviews')
.select('photos')
.select(`
id,
user_id,
created_at,
review_photos!inner(
cloudflare_image_url,
caption,
order_index,
id
)
`)
.eq('ride_id', rideId)
.eq('moderation_status', 'approved')
.not('photos', 'is', null)
.order('created_at', { ascending: false })
.limit(10);
if (!error && data) {
const allPhotos: Photo[] = [];
data.forEach((review: any) => {
if (review.photos && Array.isArray(review.photos)) {
review.photos.forEach((photo: any) => {
if (review.review_photos && Array.isArray(review.review_photos)) {
review.review_photos.forEach((photo: any) => {
if (allPhotos.length < 4) {
allPhotos.push({
id: photo.id || Math.random().toString(),
image_url: photo.image_url || photo.url,
image_url: photo.cloudflare_image_url,
caption: photo.caption || null
});
}