Cache photo meta queries
This commit is contained in:
parent
2ce07492ed
commit
4eacce7456
@ -1,9 +1,8 @@
|
|||||||
import AdminChildPage from '@/components/AdminChildPage';
|
import AdminChildPage from '@/components/AdminChildPage';
|
||||||
import { redirect } from 'next/navigation';
|
import { redirect } from 'next/navigation';
|
||||||
import { getPhotosCached } from '@/photo/cache';
|
import { getPhotosCached, getPhotosMetaCached } from '@/photo/cache';
|
||||||
import { PATH_ADMIN, PATH_ADMIN_RECIPES, pathForRecipe } from '@/app/paths';
|
import { PATH_ADMIN, PATH_ADMIN_RECIPES, pathForRecipe } from '@/app/paths';
|
||||||
import PhotoLightbox from '@/photo/PhotoLightbox';
|
import PhotoLightbox from '@/photo/PhotoLightbox';
|
||||||
import { getPhotosMeta } from '@/photo/db/query';
|
|
||||||
import AdminRecipeBadge from '@/admin/AdminRecipeBadge';
|
import AdminRecipeBadge from '@/admin/AdminRecipeBadge';
|
||||||
import AdminRecipeForm from '@/admin/AdminRecipeForm';
|
import AdminRecipeForm from '@/admin/AdminRecipeForm';
|
||||||
import { getPhotoWithRecipeFromPhotos } from '@/recipe';
|
import { getPhotoWithRecipeFromPhotos } from '@/recipe';
|
||||||
@ -26,7 +25,7 @@ export default async function RecipePageEdit({
|
|||||||
{ count },
|
{ count },
|
||||||
photos,
|
photos,
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
getPhotosMeta({ recipe }),
|
getPhotosMetaCached({ recipe }),
|
||||||
getPhotosCached({ recipe, limit: MAX_PHOTO_TO_SHOW }),
|
getPhotosCached({ recipe, limit: MAX_PHOTO_TO_SHOW }),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,9 @@
|
|||||||
import AdminChildPage from '@/components/AdminChildPage';
|
import AdminChildPage from '@/components/AdminChildPage';
|
||||||
import { redirect } from 'next/navigation';
|
import { redirect } from 'next/navigation';
|
||||||
import { getPhotosCached } from '@/photo/cache';
|
import { getPhotosCached, getPhotosMetaCached } from '@/photo/cache';
|
||||||
import AdminTagForm from '@/admin/AdminTagForm';
|
import AdminTagForm from '@/admin/AdminTagForm';
|
||||||
import { PATH_ADMIN, PATH_ADMIN_TAGS, pathForTag } from '@/app/paths';
|
import { PATH_ADMIN, PATH_ADMIN_TAGS, pathForTag } from '@/app/paths';
|
||||||
import PhotoLightbox from '@/photo/PhotoLightbox';
|
import PhotoLightbox from '@/photo/PhotoLightbox';
|
||||||
import { getPhotosMeta } from '@/photo/db/query';
|
|
||||||
import AdminTagBadge from '@/admin/AdminTagBadge';
|
import AdminTagBadge from '@/admin/AdminTagBadge';
|
||||||
|
|
||||||
const MAX_PHOTO_TO_SHOW = 6;
|
const MAX_PHOTO_TO_SHOW = 6;
|
||||||
@ -24,7 +23,7 @@ export default async function PhotoPageEdit({
|
|||||||
{ count },
|
{ count },
|
||||||
photos,
|
photos,
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
getPhotosMeta({ tag }),
|
getPhotosMetaCached({ tag }),
|
||||||
getPhotosCached({ tag, limit: MAX_PHOTO_TO_SHOW }),
|
getPhotosCached({ tag, limit: MAX_PHOTO_TO_SHOW }),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@ -5,8 +5,9 @@ import {
|
|||||||
import PhotosEmptyState from '@/photo/PhotosEmptyState';
|
import PhotosEmptyState from '@/photo/PhotosEmptyState';
|
||||||
import { Metadata } from 'next/types';
|
import { Metadata } from 'next/types';
|
||||||
import { cache } from 'react';
|
import { cache } from 'react';
|
||||||
import { getPhotos, getPhotosMeta } from '@/photo/db/query';
|
import { getPhotos } from '@/photo/db/query';
|
||||||
import PhotoFeedPage from '@/photo/PhotoFeedPage';
|
import PhotoFeedPage from '@/photo/PhotoFeedPage';
|
||||||
|
import { getPhotosMetaCached } from '@/photo/cache';
|
||||||
|
|
||||||
export const dynamic = 'force-static';
|
export const dynamic = 'force-static';
|
||||||
export const maxDuration = 60;
|
export const maxDuration = 60;
|
||||||
@ -28,7 +29,7 @@ export default async function FeedPage() {
|
|||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
getPhotosCached()
|
getPhotosCached()
|
||||||
.catch(() => []),
|
.catch(() => []),
|
||||||
getPhotosMeta()
|
getPhotosMetaCached()
|
||||||
.then(({ count }) => count)
|
.then(({ count }) => count)
|
||||||
.catch(() => 0),
|
.catch(() => 0),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -11,9 +11,8 @@ import {
|
|||||||
absolutePathForPhotoImage,
|
absolutePathForPhotoImage,
|
||||||
} from '@/app/paths';
|
} from '@/app/paths';
|
||||||
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
||||||
import { getPhotosNearIdCached } from '@/photo/cache';
|
import { getPhotosNearIdCached, getPhotosMetaCached } from '@/photo/cache';
|
||||||
import { cache } from 'react';
|
import { cache } from 'react';
|
||||||
import { getPhotosMeta } from '@/photo/db/query';
|
|
||||||
import { getFocalLengthFromString } from '@/focal';
|
import { getFocalLengthFromString } from '@/focal';
|
||||||
|
|
||||||
const getPhotosNearIdCachedCached = cache((photoId: string, focal: number) =>
|
const getPhotosNearIdCachedCached = cache((photoId: string, focal: number) =>
|
||||||
@ -72,7 +71,7 @@ export default async function PhotoFocalLengthPage({
|
|||||||
|
|
||||||
if (!photo) { redirect(PATH_ROOT); }
|
if (!photo) { redirect(PATH_ROOT); }
|
||||||
|
|
||||||
const { count, dateRange } = await getPhotosMeta({ focal });
|
const { count, dateRange } = await getPhotosMetaCached({ focal });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PhotoDetailPage {...{
|
<PhotoDetailPage {...{
|
||||||
|
|||||||
@ -4,10 +4,11 @@ import {
|
|||||||
} from '@/photo';
|
} from '@/photo';
|
||||||
import PhotosEmptyState from '@/photo/PhotosEmptyState';
|
import PhotosEmptyState from '@/photo/PhotosEmptyState';
|
||||||
import { Metadata } from 'next/types';
|
import { Metadata } from 'next/types';
|
||||||
import { getPhotos, getPhotosMeta } from '@/photo/db/query';
|
import { getPhotos } from '@/photo/db/query';
|
||||||
import { cache } from 'react';
|
import { cache } from 'react';
|
||||||
import PhotoGridPage from '@/photo/PhotoGridPage';
|
import PhotoGridPage from '@/photo/PhotoGridPage';
|
||||||
import { getDataForCategoriesCached } from '@/category/cache';
|
import { getDataForCategoriesCached } from '@/category/cache';
|
||||||
|
import { getPhotosMetaCached } from '@/photo/cache';
|
||||||
|
|
||||||
export const dynamic = 'force-static';
|
export const dynamic = 'force-static';
|
||||||
|
|
||||||
@ -29,7 +30,7 @@ export default async function GridPage() {
|
|||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
getPhotosCached()
|
getPhotosCached()
|
||||||
.catch(() => []),
|
.catch(() => []),
|
||||||
getPhotosMeta()
|
getPhotosMetaCached()
|
||||||
.then(({ count }) => count)
|
.then(({ count }) => count)
|
||||||
.catch(() => 0),
|
.catch(() => 0),
|
||||||
getDataForCategoriesCached(),
|
getDataForCategoriesCached(),
|
||||||
|
|||||||
@ -2,8 +2,7 @@ import {
|
|||||||
INFINITE_SCROLL_GRID_INITIAL,
|
INFINITE_SCROLL_GRID_INITIAL,
|
||||||
INFINITE_SCROLL_GRID_MULTIPLE,
|
INFINITE_SCROLL_GRID_MULTIPLE,
|
||||||
} from '@/photo';
|
} from '@/photo';
|
||||||
import { getPhotosCached } from '@/photo/cache';
|
import { getPhotosCached, getPhotosMetaCached } from '@/photo/cache';
|
||||||
import { getPhotosMeta } from '@/photo/db/query';
|
|
||||||
import StaggeredOgPhotos from '@/photo/StaggeredOgPhotos';
|
import StaggeredOgPhotos from '@/photo/StaggeredOgPhotos';
|
||||||
import StaggeredOgPhotosInfinite from '@/photo/StaggeredOgPhotosInfinite';
|
import StaggeredOgPhotosInfinite from '@/photo/StaggeredOgPhotosInfinite';
|
||||||
|
|
||||||
@ -14,7 +13,7 @@ export default async function OGPage() {
|
|||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
getPhotosCached({ limit: INFINITE_SCROLL_GRID_INITIAL })
|
getPhotosCached({ limit: INFINITE_SCROLL_GRID_INITIAL })
|
||||||
.catch(() => []),
|
.catch(() => []),
|
||||||
getPhotosMeta()
|
getPhotosMetaCached()
|
||||||
.then(({ count }) => count)
|
.then(({ count }) => count)
|
||||||
.catch(() => 0),
|
.catch(() => 0),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -6,12 +6,13 @@ import {
|
|||||||
import PhotosEmptyState from '@/photo/PhotosEmptyState';
|
import PhotosEmptyState from '@/photo/PhotosEmptyState';
|
||||||
import { Metadata } from 'next/types';
|
import { Metadata } from 'next/types';
|
||||||
import { cache } from 'react';
|
import { cache } from 'react';
|
||||||
import { getPhotos, getPhotosMeta } from '@/photo/db/query';
|
import { getPhotos } from '@/photo/db/query';
|
||||||
import { GRID_HOMEPAGE_ENABLED } from '@/app/config';
|
import { GRID_HOMEPAGE_ENABLED } from '@/app/config';
|
||||||
import { NULL_CATEGORY_DATA } from '@/category/data';
|
import { NULL_CATEGORY_DATA } from '@/category/data';
|
||||||
import PhotoFeedPage from '@/photo/PhotoFeedPage';
|
import PhotoFeedPage from '@/photo/PhotoFeedPage';
|
||||||
import PhotoGridPage from '@/photo/PhotoGridPage';
|
import PhotoGridPage from '@/photo/PhotoGridPage';
|
||||||
import { getDataForCategoriesCached } from '@/category/cache';
|
import { getDataForCategoriesCached } from '@/category/cache';
|
||||||
|
import { getPhotosMetaCached } from '@/photo/cache';
|
||||||
export const dynamic = 'force-static';
|
export const dynamic = 'force-static';
|
||||||
export const maxDuration = 60;
|
export const maxDuration = 60;
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ export default async function HomePage() {
|
|||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
getPhotosCached()
|
getPhotosCached()
|
||||||
.catch(() => []),
|
.catch(() => []),
|
||||||
getPhotosMeta()
|
getPhotosMetaCached()
|
||||||
.then(({ count }) => count)
|
.then(({ count }) => count)
|
||||||
.catch(() => 0),
|
.catch(() => 0),
|
||||||
GRID_HOMEPAGE_ENABLED
|
GRID_HOMEPAGE_ENABLED
|
||||||
|
|||||||
@ -11,9 +11,8 @@ import {
|
|||||||
absolutePathForPhotoImage,
|
absolutePathForPhotoImage,
|
||||||
} from '@/app/paths';
|
} from '@/app/paths';
|
||||||
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
||||||
import { getPhotosNearIdCached } from '@/photo/cache';
|
import { getPhotosMetaCached, getPhotosNearIdCached } from '@/photo/cache';
|
||||||
import { cache } from 'react';
|
import { cache } from 'react';
|
||||||
import { getPhotosMeta } from '@/photo/db/query';
|
|
||||||
|
|
||||||
const getPhotosNearIdCachedCached = cache((
|
const getPhotosNearIdCachedCached = cache((
|
||||||
photoId: string,
|
photoId: string,
|
||||||
@ -74,7 +73,7 @@ export default async function PhotoRecipePage({
|
|||||||
|
|
||||||
if (!photo) { redirect(PATH_ROOT); }
|
if (!photo) { redirect(PATH_ROOT); }
|
||||||
|
|
||||||
const { count, dateRange } = await getPhotosMeta({ recipe });
|
const { count, dateRange } = await getPhotosMetaCached({ recipe });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PhotoDetailPage {...{
|
<PhotoDetailPage {...{
|
||||||
|
|||||||
@ -11,9 +11,8 @@ import {
|
|||||||
absolutePathForPhotoImage,
|
absolutePathForPhotoImage,
|
||||||
} from '@/app/paths';
|
} from '@/app/paths';
|
||||||
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
||||||
import { getPhotosNearIdCached } from '@/photo/cache';
|
import { getPhotosMetaCached, getPhotosNearIdCached } from '@/photo/cache';
|
||||||
import { cache } from 'react';
|
import { cache } from 'react';
|
||||||
import { getPhotosMeta } from '@/photo/db/query';
|
|
||||||
|
|
||||||
const getPhotosNearIdCachedCached = cache((photoId: string, tag: string) =>
|
const getPhotosNearIdCachedCached = cache((photoId: string, tag: string) =>
|
||||||
getPhotosNearIdCached(
|
getPhotosNearIdCached(
|
||||||
@ -71,7 +70,7 @@ export default async function PhotoTagPage({
|
|||||||
|
|
||||||
if (!photo) { redirect(PATH_ROOT); }
|
if (!photo) { redirect(PATH_ROOT); }
|
||||||
|
|
||||||
const { count, dateRange } = await getPhotosMeta({ tag });
|
const { count, dateRange } = await getPhotosMetaCached({ tag });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PhotoDetailPage {...{
|
<PhotoDetailPage {...{
|
||||||
|
|||||||
@ -5,9 +5,9 @@ import {
|
|||||||
} from '@/photo';
|
} from '@/photo';
|
||||||
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
||||||
import {
|
import {
|
||||||
|
getPhotosMetaCached,
|
||||||
getPhotosNearIdCached,
|
getPhotosNearIdCached,
|
||||||
} from '@/photo/cache';
|
} from '@/photo/cache';
|
||||||
import { getPhotosMeta } from '@/photo/db/query';
|
|
||||||
import { PATH_ROOT, absolutePathForPhoto } from '@/app/paths';
|
import { PATH_ROOT, absolutePathForPhoto } from '@/app/paths';
|
||||||
import { TAG_HIDDEN } from '@/tag';
|
import { TAG_HIDDEN } from '@/tag';
|
||||||
import { Metadata } from 'next';
|
import { Metadata } from 'next';
|
||||||
@ -63,7 +63,7 @@ export default async function PhotoTagHiddenPage({
|
|||||||
|
|
||||||
if (!photo) { redirect(PATH_ROOT); }
|
if (!photo) { redirect(PATH_ROOT); }
|
||||||
|
|
||||||
const { count, dateRange } = await getPhotosMeta({ hidden: 'only' });
|
const { count, dateRange } = await getPhotosMetaCached({ hidden: 'only' });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PhotoDetailPage {...{
|
<PhotoDetailPage {...{
|
||||||
|
|||||||
@ -2,8 +2,7 @@ import AnimateItems from '@/components/AnimateItems';
|
|||||||
import Note from '@/components/Note';
|
import Note from '@/components/Note';
|
||||||
import AppGrid from '@/components/AppGrid';
|
import AppGrid from '@/components/AppGrid';
|
||||||
import PhotoGrid from '@/photo/PhotoGrid';
|
import PhotoGrid from '@/photo/PhotoGrid';
|
||||||
import { getPhotosNoStore } from '@/photo/cache';
|
import { getPhotosMetaCached, getPhotosNoStore } from '@/photo/cache';
|
||||||
import { getPhotosMeta } from '@/photo/db/query';
|
|
||||||
import { absolutePathForTag } from '@/app/paths';
|
import { absolutePathForTag } from '@/app/paths';
|
||||||
import { TAG_HIDDEN, descriptionForTaggedPhotos, titleForTag } from '@/tag';
|
import { TAG_HIDDEN, descriptionForTaggedPhotos, titleForTag } from '@/tag';
|
||||||
import HiddenHeader from '@/tag/HiddenHeader';
|
import HiddenHeader from '@/tag/HiddenHeader';
|
||||||
@ -11,7 +10,7 @@ import { Metadata } from 'next';
|
|||||||
import { cache } from 'react';
|
import { cache } from 'react';
|
||||||
|
|
||||||
const getPhotosHiddenMetaCached = cache(() =>
|
const getPhotosHiddenMetaCached = cache(() =>
|
||||||
getPhotosMeta({ hidden: 'only' }));
|
getPhotosMetaCached({ hidden: 'only' }));
|
||||||
|
|
||||||
export async function generateMetadata(): Promise<Metadata> {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
const { count, dateRange } = await getPhotosHiddenMetaCached();
|
const { count, dateRange } = await getPhotosHiddenMetaCached();
|
||||||
|
|||||||
@ -299,7 +299,6 @@ export const ADMIN_DEBUG_TOOLS_ENABLED = process.env.ADMIN_DEBUG_TOOLS === '1';
|
|||||||
export const ADMIN_DB_OPTIMIZE_ENABLED = process.env.ADMIN_DB_OPTIMIZE === '1';
|
export const ADMIN_DB_OPTIMIZE_ENABLED = process.env.ADMIN_DB_OPTIMIZE === '1';
|
||||||
export const ADMIN_SQL_DEBUG_ENABLED =
|
export const ADMIN_SQL_DEBUG_ENABLED =
|
||||||
process.env.ADMIN_SQL_DEBUG === '1';
|
process.env.ADMIN_SQL_DEBUG === '1';
|
||||||
// && !IS_BUILDING;
|
|
||||||
|
|
||||||
export const APP_CONFIGURATION = {
|
export const APP_CONFIGURATION = {
|
||||||
// Storage
|
// Storage
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user