diff --git a/src/admin/AdminNav.tsx b/src/admin/AdminNav.tsx index 0a4b26f2..ce1d1964 100644 --- a/src/admin/AdminNav.tsx +++ b/src/admin/AdminNav.tsx @@ -1,6 +1,6 @@ import { getStorageUploadUrlsNoStore } from '@/services/storage/cache'; import { - getPhotosCountIncludingHiddenCached, + getPhotosMetaCached, getPhotosMostRecentUpdateCached, getUniqueTagsCached, } from '@/photo/cache'; @@ -18,7 +18,9 @@ export default async function AdminNav() { countTags, mostRecentPhotoUpdateTime, ] = await Promise.all([ - getPhotosCountIncludingHiddenCached().catch(() => 0), + getPhotosMetaCached({ hidden: 'include' }) + .then(({ count }) => count) + .catch(() => 0), getStorageUploadUrlsNoStore() .then(urls => urls.length) .catch(e => { diff --git a/src/app/admin/photos/page.tsx b/src/app/admin/photos/page.tsx index 8a0c4e54..66609ca0 100644 --- a/src/app/admin/photos/page.tsx +++ b/src/app/admin/photos/page.tsx @@ -1,15 +1,15 @@ import PhotoUpload from '@/photo/PhotoUpload'; import { clsx } from 'clsx/lite'; import SiteGrid from '@/components/SiteGrid'; -import { getPhotosCountIncludingHiddenCached } from '@/photo/cache'; import AdminUploadsTable from '@/admin/AdminUploadsTable'; import { PRO_MODE_ENABLED } from '@/site/config'; import { getStoragePhotoUrlsNoStore } from '@/services/storage/cache'; -import { getPhotos } from '@/photo/db'; +import { getPhotos } from '@/photo/db/query'; import { revalidatePath } from 'next/cache'; import AdminPhotosTable from '@/admin/AdminPhotosTable'; import AdminPhotosTableInfinite from '@/admin/AdminPhotosTableInfinite'; +import { getPhotosMetaCached } from '@/photo/cache'; const DEBUG_PHOTO_BLOBS = false; @@ -27,7 +27,9 @@ export default async function AdminPhotosPage() { sortBy: 'createdAt', limit: INFINITE_SCROLL_INITIAL_ADMIN_PHOTOS, }).catch(() => []), - getPhotosCountIncludingHiddenCached().catch(() => 0), + getPhotosMetaCached({ hidden: 'include'}) + .then(({ count }) => count) + .catch(() => 0), DEBUG_PHOTO_BLOBS ? getStoragePhotoUrlsNoStore() : [], diff --git a/src/app/admin/tags/[tag]/edit/page.tsx b/src/app/admin/tags/[tag]/edit/page.tsx index 7ba178ed..bfeee049 100644 --- a/src/app/admin/tags/[tag]/edit/page.tsx +++ b/src/app/admin/tags/[tag]/edit/page.tsx @@ -4,7 +4,7 @@ import { getPhotosCached } from '@/photo/cache'; import TagForm from '@/tag/TagForm'; import { PATH_ADMIN, PATH_ADMIN_TAGS, pathForTag } from '@/site/paths'; import PhotoLightbox from '@/photo/PhotoLightbox'; -import { getPhotosTagMeta } from '@/photo/db'; +import { getPhotosMeta } from '@/photo/db/query'; import AdminTagBadge from '@/admin/AdminTagBadge'; const MAX_PHOTO_TO_SHOW = 6; @@ -22,7 +22,7 @@ export default async function PhotoPageEdit({ { count }, photos, ] = await Promise.all([ - getPhotosTagMeta(tag), + getPhotosMeta({ tag }), getPhotosCached({ tag, limit: MAX_PHOTO_TO_SHOW }), ]); diff --git a/src/app/film/[simulation]/[photoId]/layout.tsx b/src/app/film/[simulation]/[photoId]/layout.tsx index cba372b1..4773e8da 100644 --- a/src/app/film/[simulation]/[photoId]/layout.tsx +++ b/src/app/film/[simulation]/[photoId]/layout.tsx @@ -14,7 +14,7 @@ import PhotoDetailPage from '@/photo/PhotoDetailPage'; import { ReactNode, cache } from 'react'; import { FilmSimulation } from '@/simulation'; import { - getPhotosFilmSimulationMetaCached, + getPhotosMetaCached, getPhotosNearIdCached, } from '@/photo/cache'; @@ -70,8 +70,7 @@ export default async function PhotoFilmSimulationPage({ if (!photo) { redirect(PATH_ROOT); } - const { count, dateRange } = - await getPhotosFilmSimulationMetaCached(simulation); + const { count, dateRange } = await getPhotosMetaCached({ simulation }); return <> {children} diff --git a/src/app/grid/page.tsx b/src/app/grid/page.tsx index aa5b2328..0b0cb4ab 100644 --- a/src/app/grid/page.tsx +++ b/src/app/grid/page.tsx @@ -6,7 +6,7 @@ import PhotosEmptyState from '@/photo/PhotosEmptyState'; import { Metadata } from 'next/types'; import PhotoGridSidebar from '@/photo/PhotoGridSidebar'; import { getPhotoSidebarData } from '@/photo/data'; -import { getPhotos } from '@/photo/db'; +import { getPhotos } from '@/photo/db/query'; import { cache } from 'react'; import PhotoGridPage from '@/photo/PhotoGridPage'; import { PATH_GRID } from '@/site/paths'; diff --git a/src/app/og/page.tsx b/src/app/og/page.tsx index 295c90cd..1394c43f 100644 --- a/src/app/og/page.tsx +++ b/src/app/og/page.tsx @@ -2,7 +2,8 @@ import { INFINITE_SCROLL_GRID_PHOTO_INITIAL, INFINITE_SCROLL_GRID_PHOTO_MULTIPLE, } from '@/photo'; -import { getPhotosCached, getPhotosCountCached } from '@/photo/cache'; +import { getPhotosCached } from '@/photo/cache'; +import { getPhotosMeta } from '@/photo/db/query'; import StaggeredOgPhotos from '@/photo/StaggeredOgPhotos'; import StaggeredOgPhotosInfinite from '@/photo/StaggeredOgPhotosInfinite'; @@ -12,7 +13,9 @@ export default async function GridPage() { count, ] = await Promise.all([ getPhotosCached({ limit: INFINITE_SCROLL_GRID_PHOTO_INITIAL }), - getPhotosCountCached(), + getPhotosMeta() + .then(({ count }) => count) + .catch(() => 0), ]); return ( diff --git a/src/app/p/[photoId]/image/route.tsx b/src/app/p/[photoId]/image/route.tsx index 73dbdfdf..60ceefd1 100644 --- a/src/app/p/[photoId]/image/route.tsx +++ b/src/app/p/[photoId]/image/route.tsx @@ -5,7 +5,8 @@ import { getIBMPlexMonoMedium } from '@/site/font'; import { ImageResponse } from 'next/og'; import { getImageResponseCacheControlHeaders } from '@/image-response/cache'; import { IS_PRODUCTION, STATICALLY_OPTIMIZED_OG_IMAGES } from '@/site/config'; -import { GENERATE_STATIC_PARAMS_LIMIT, getPhotoIds } from '@/photo/db'; +import { getPhotoIds } from '@/photo/db/query'; +import { GENERATE_STATIC_PARAMS_LIMIT } from '@/photo/db'; import { isNextImageReadyBasedOnPhotos } from '@/photo'; export let generateStaticParams: diff --git a/src/app/p/[photoId]/layout.tsx b/src/app/p/[photoId]/layout.tsx index 26415c8a..e40e7d9c 100644 --- a/src/app/p/[photoId]/layout.tsx +++ b/src/app/p/[photoId]/layout.tsx @@ -13,7 +13,8 @@ import { import PhotoDetailPage from '@/photo/PhotoDetailPage'; import { getPhotosNearIdCached } from '@/photo/cache'; import { IS_PRODUCTION, STATICALLY_OPTIMIZED_PAGES } from '@/site/config'; -import { GENERATE_STATIC_PARAMS_LIMIT, getPhotoIds } from '@/photo/db'; +import { getPhotoIds } from '@/photo/db/query'; +import { GENERATE_STATIC_PARAMS_LIMIT } from '@/photo/db'; import { ReactNode, cache } from 'react'; const getPhotosNearIdCachedCached = cache((photoId: string) => diff --git a/src/app/page.tsx b/src/app/page.tsx index 8fc3e845..c9dfc2bc 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -8,7 +8,7 @@ import { Metadata } from 'next/types'; import { MAX_PHOTOS_TO_SHOW_OG } from '@/image-response'; import PhotosLarge from '@/photo/PhotosLarge'; import { cache } from 'react'; -import { getPhotos, getPhotosCount } from '@/photo/db'; +import { getPhotos, getPhotosMeta } from '@/photo/db/query'; import PhotosLargeInfinite from '@/photo/PhotosLargeInfinite'; export const dynamic = 'force-static'; @@ -32,7 +32,8 @@ export default async function HomePage() { limit: INFINITE_SCROLL_LARGE_PHOTO_INITIAL, }) .catch(() => []), - getPhotosCount() + getPhotosMeta() + .then(({ count }) => count) .catch(() => 0), ]); diff --git a/src/app/shot-on/[make]/[model]/[photoId]/layout.tsx b/src/app/shot-on/[make]/[model]/[photoId]/layout.tsx index d1a5c04c..42efcca0 100644 --- a/src/app/shot-on/[make]/[model]/[photoId]/layout.tsx +++ b/src/app/shot-on/[make]/[model]/[photoId]/layout.tsx @@ -12,7 +12,7 @@ import { } from '@/site/paths'; import PhotoDetailPage from '@/photo/PhotoDetailPage'; import { - getPhotosCameraMetaCached, + getPhotosMetaCached, getPhotosNearIdCached, } from '@/photo/cache'; import { @@ -79,7 +79,7 @@ export default async function PhotoCameraPage({ const camera = cameraFromPhoto(photo, { make, model }); - const { count, dateRange } = await getPhotosCameraMetaCached(camera); + const { count, dateRange } = await getPhotosMetaCached({ camera }); return <> {children} diff --git a/src/app/tag/[tag]/[photoId]/layout.tsx b/src/app/tag/[tag]/[photoId]/layout.tsx index 03c25c75..5de147fd 100644 --- a/src/app/tag/[tag]/[photoId]/layout.tsx +++ b/src/app/tag/[tag]/[photoId]/layout.tsx @@ -11,11 +11,9 @@ import { absolutePathForPhotoImage, } from '@/site/paths'; import PhotoDetailPage from '@/photo/PhotoDetailPage'; -import { - getPhotosNearIdCached, - getPhotosTagMetaCached, -} from '@/photo/cache'; +import { getPhotosNearIdCached } from '@/photo/cache'; import { ReactNode, cache } from 'react'; +import { getPhotosMeta } from '@/photo/db/query'; const getPhotosNearIdCachedCached = cache((photoId: string, tag: string) => getPhotosNearIdCached( @@ -66,7 +64,7 @@ export default async function PhotoTagPage({ if (!photo) { redirect(PATH_ROOT); } - const { count, dateRange } = await getPhotosTagMetaCached(tag); + const { count, dateRange } = await getPhotosMeta({ tag }); return <> {children} diff --git a/src/app/tag/hidden/[photoId]/page.tsx b/src/app/tag/hidden/[photoId]/page.tsx index 2382bd3b..954fca0c 100644 --- a/src/app/tag/hidden/[photoId]/page.tsx +++ b/src/app/tag/hidden/[photoId]/page.tsx @@ -6,8 +6,8 @@ import { import PhotoDetailPage from '@/photo/PhotoDetailPage'; import { getPhotosNearIdCached, - getPhotosTagHiddenMetaCached, } from '@/photo/cache'; +import { getPhotosMeta } from '@/photo/db/query'; import { PATH_ROOT, absolutePathForPhoto } from '@/site/paths'; import { TAG_HIDDEN } from '@/tag'; import { Metadata } from 'next'; @@ -59,7 +59,7 @@ export default async function PhotoTagHiddenPage({ if (!photo) { redirect(PATH_ROOT); } - const { count, dateRange } = await getPhotosTagHiddenMetaCached(); + const { count, dateRange } = await getPhotosMeta({ hidden: 'only' }); return (