Add new layout to album pages and remove tests and PhotoGrid

This commit is contained in:
Justin Edmund 2025-06-16 10:10:59 +01:00
parent 6132c17a9b
commit f540aed895
4 changed files with 3 additions and 275 deletions

View file

@ -1,122 +0,0 @@
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
async function checkPhotosDisplay() {
try {
console.log('=== Checking Photos Display ===\n')
// Check albums marked for photography
const photographyAlbums = await prisma.album.findMany({
where: {
status: 'published',
isPhotography: true
},
include: {
photos: {
where: {
status: 'published'
}
}
}
})
console.log(`Found ${photographyAlbums.length} published photography albums:`)
photographyAlbums.forEach((album) => {
console.log(`- "${album.title}" (${album.slug}): ${album.photos.length} published photos`)
})
// Check individual photos marked to show in photos
const individualPhotos = await prisma.photo.findMany({
where: {
status: 'published',
showInPhotos: true,
albumId: null
}
})
console.log(`\nFound ${individualPhotos.length} individual photos marked to show in Photos`)
individualPhotos.forEach((photo) => {
console.log(`- Photo ID ${photo.id}: ${photo.filename}`)
})
// Check if there are any published photos in albums
const photosInAlbums = await prisma.photo.findMany({
where: {
status: 'published',
showInPhotos: true,
albumId: { not: null }
},
include: {
album: true
}
})
console.log(
`\nFound ${photosInAlbums.length} published photos in albums with showInPhotos=true`
)
const albumGroups = photosInAlbums.reduce(
(acc, photo) => {
const albumTitle = photo.album?.title || 'Unknown'
acc[albumTitle] = (acc[albumTitle] || 0) + 1
return acc
},
{} as Record<string, number>
)
Object.entries(albumGroups).forEach(([album, count]) => {
console.log(`- Album "${album}": ${count} photos`)
})
// Check media marked as photography
const photographyMedia = await prisma.media.findMany({
where: {
isPhotography: true
}
})
console.log(`\nFound ${photographyMedia.length} media items marked as photography`)
// Check for any photos regardless of status
const allPhotos = await prisma.photo.findMany({
include: {
album: true
}
})
console.log(`\nTotal photos in database: ${allPhotos.length}`)
const statusCounts = allPhotos.reduce(
(acc, photo) => {
acc[photo.status] = (acc[photo.status] || 0) + 1
return acc
},
{} as Record<string, number>
)
Object.entries(statusCounts).forEach(([status, count]) => {
console.log(`- Status "${status}": ${count} photos`)
})
// Check all albums
const allAlbums = await prisma.album.findMany({
include: {
_count: {
select: { photos: true }
}
}
})
console.log(`\nTotal albums in database: ${allAlbums.length}`)
allAlbums.forEach((album) => {
console.log(
`- "${album.title}" (${album.slug}): status=${album.status}, isPhotography=${album.isPhotography}, photos=${album._count.photos}`
)
})
} catch (error) {
console.error('Error checking photos:', error)
} finally {
await prisma.$disconnect()
}
}
checkPhotosDisplay()

View file

@ -1,109 +0,0 @@
import { PrismaClient } from '@prisma/client'
import 'dotenv/config'
const prisma = new PrismaClient()
async function testPhotoQueries() {
console.log('=== Testing Photo Queries ===\n')
try {
// Query 1: Count all photos
const totalPhotos = await prisma.photo.count()
console.log(`Total photos in database: ${totalPhotos}`)
// Query 2: Photos with showInPhotos=true and albumId=null
const photosForDisplay = await prisma.photo.findMany({
where: {
showInPhotos: true,
albumId: null
},
select: {
id: true,
slug: true,
filename: true,
status: true,
showInPhotos: true,
albumId: true,
publishedAt: true,
createdAt: true
}
})
console.log(`\nPhotos with showInPhotos=true and albumId=null: ${photosForDisplay.length}`)
photosForDisplay.forEach((photo) => {
console.log(
` - ID: ${photo.id}, Status: ${photo.status}, Slug: ${photo.slug || 'none'}, File: ${photo.filename}`
)
})
// Query 3: Check status distribution
const statusCounts = await prisma.photo.groupBy({
by: ['status'],
where: {
showInPhotos: true,
albumId: null
},
_count: {
id: true
}
})
console.log('\nStatus distribution for photos with showInPhotos=true and albumId=null:')
statusCounts.forEach(({ status, _count }) => {
console.log(` - ${status}: ${_count.id}`)
})
// Query 4: Published photos that should appear
const publishedPhotos = await prisma.photo.findMany({
where: {
status: 'published',
showInPhotos: true,
albumId: null
}
})
console.log(
`\nPublished photos (status='published', showInPhotos=true, albumId=null): ${publishedPhotos.length}`
)
publishedPhotos.forEach((photo) => {
console.log(` - ID: ${photo.id}, File: ${photo.filename}, Published: ${photo.publishedAt}`)
})
// Query 5: Check if there are any draft photos that might need publishing
const draftPhotos = await prisma.photo.findMany({
where: {
status: 'draft',
showInPhotos: true,
albumId: null
}
})
if (draftPhotos.length > 0) {
console.log(`\n⚠ Found ${draftPhotos.length} draft photos with showInPhotos=true:`)
draftPhotos.forEach((photo) => {
console.log(` - ID: ${photo.id}, File: ${photo.filename}`)
})
console.log('These photos need to be published to appear in the photos page!')
}
// Query 6: Check unique statuses in the database
const uniqueStatuses = await prisma.photo.findMany({
distinct: ['status'],
select: {
status: true
}
})
console.log('\nAll unique status values in the database:')
uniqueStatuses.forEach(({ status }) => {
console.log(` - "${status}"`)
})
} catch (error) {
console.error('Error running queries:', error)
} finally {
await prisma.$disconnect()
}
}
// Run the test
testPhotoQueries()

View file

@ -1,41 +0,0 @@
<script lang="ts">
import PhotoItem from '$components/PhotoItem.svelte'
import type { PhotoItem as PhotoItemType } from '$lib/types/photos'
const {
photoItems,
albumSlug
}: {
photoItems: PhotoItemType[]
albumSlug?: string
} = $props()
</script>
<div class="photo-grid-container">
<div class="photo-grid">
{#each photoItems as item}
<PhotoItem {item} {albumSlug} />
{/each}
</div>
</div>
<style lang="scss">
.photo-grid-container {
width: 100%;
}
.photo-grid {
columns: 3;
column-gap: $unit-3x;
margin: 0;
@include breakpoint('tablet') {
columns: 2;
column-gap: $unit-2x;
}
@include breakpoint('phone') {
columns: 1;
}
}
</style>

View file

@ -1,5 +1,5 @@
<script lang="ts">
import PhotoGrid from '$components/PhotoGrid.svelte'
import MasonryPhotoGrid from '$components/MasonryPhotoGrid.svelte'
import BackButton from '$components/BackButton.svelte'
import { generateMetaTags, generateImageGalleryJsonLd } from '$lib/utils/metadata'
import { page } from '$app/stores'
@ -12,7 +12,7 @@
const photo = $derived(data.photo)
const error = $derived(data.error)
// Transform album data to PhotoItem format for PhotoGrid
// Transform album data to PhotoItem format for MasonryPhotoGrid
const photoItems = $derived(
album?.photos?.map((photo: any) => ({
id: `photo-${photo.id}`,
@ -145,7 +145,7 @@
<!-- Photo Grid -->
{#if photoItems.length > 0}
<PhotoGrid {photoItems} albumSlug={album.slug} />
<MasonryPhotoGrid {photoItems} albumSlug={album.slug} />
{:else}
<div class="empty-album">
<p>This album doesn't contain any photos yet.</p>