mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 17:11:13 -05:00
Refactor log_request_metadata function
This commit is contained in:
@@ -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
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user