diff --git a/src/config/constants/sidebarNavs.tsx b/src/config/constants/sidebarNavs.tsx index 341c042..32570bc 100644 --- a/src/config/constants/sidebarNavs.tsx +++ b/src/config/constants/sidebarNavs.tsx @@ -7,7 +7,7 @@ export const sidebarNavs = [ icon: , }, { - title: "Find", + title: "Find Assets", link: "/find", icon: , }, diff --git a/src/config/environment.ts b/src/config/environment.ts index 488dfc9..a903517 100644 --- a/src/config/environment.ts +++ b/src/config/environment.ts @@ -8,6 +8,7 @@ export const ENV = { DB_HOST: process.env.DB_HOST as string, DB_PORT: process.env.DB_PORT as string, DB_DATABASE_NAME: process.env.DB_DATABASE_NAME as string, + DB_SCHEMA: (process.env.DB_SCHEMA as string) || 'public', JWT_SECRET: process.env.JWT_SECRET as string, SECURE_COOKIE: process.env.SECURE_COOKIE === 'true', VERSION: process.env.VERSION, diff --git a/src/pages/api/albums/[id]/assets.ts b/src/pages/api/albums/[id]/assets.ts index 4d5f79f..78b68bb 100644 --- a/src/pages/api/albums/[id]/assets.ts +++ b/src/pages/api/albums/[id]/assets.ts @@ -52,8 +52,8 @@ export default async function handler( .leftJoin(person, eq(assetFaces.personId, person.id)) .where(and( eq(albumsAssetsAssets.albumsId, id), - eq(assets.isVisible, true), - isNotNull(assets.isArchived), + eq(assets.visibility, "timeline"), + eq(assets.status, "active"), faceId ? eq(assetFaces.personId, faceId) : undefined, )) .limit(100) diff --git a/src/pages/api/albums/[id]/info.ts b/src/pages/api/albums/[id]/info.ts index 4b1f2c1..8b20d42 100644 --- a/src/pages/api/albums/[id]/info.ts +++ b/src/pages/api/albums/[id]/info.ts @@ -33,7 +33,7 @@ export default async function handler( .from(albums) .leftJoin(albumsAssetsAssets, eq(albums.id, albumsAssetsAssets.albumsId)) .leftJoin(assets, eq(albumsAssetsAssets.assetsId, assets.id)) - .leftJoin(exif, and(eq(assets.id, exif.assetId), eq(assets.isVisible, true))) + .leftJoin(exif, and(eq(assets.id, exif.assetId), eq(assets.visibility, "timeline"))) .leftJoin(assetFaces, eq(assets.id, assetFaces.assetId)) .leftJoin(person, and(eq(assetFaces.personId, person.id), eq(person.isHidden, false))) .where(and(eq(albums.ownerId, currentUser.id), eq(albums.id, id))) diff --git a/src/pages/api/albums/[id]/public-info.ts b/src/pages/api/albums/[id]/public-info.ts index 07fdef5..b844192 100644 --- a/src/pages/api/albums/[id]/public-info.ts +++ b/src/pages/api/albums/[id]/public-info.ts @@ -29,7 +29,7 @@ export default async function handler( .from(albums) .leftJoin(albumsAssetsAssets, eq(albums.id, albumsAssetsAssets.albumsId)) .leftJoin(assets, eq(albumsAssetsAssets.assetsId, assets.id)) - .leftJoin(exif, and(eq(assets.id, exif.assetId), eq(assets.isVisible, true))) + .leftJoin(exif, and(eq(assets.id, exif.assetId), eq(assets.visibility, "timeline"))) .leftJoin(assetFaces, eq(assets.id, assetFaces.assetId)) .leftJoin(person, and(eq(assetFaces.personId, person.id), eq(person.isHidden, false))) .where(and(eq(albums.id, id))) diff --git a/src/pages/api/albums/list.ts b/src/pages/api/albums/list.ts index 0624c44..a3a7c2d 100644 --- a/src/pages/api/albums/list.ts +++ b/src/pages/api/albums/list.ts @@ -72,8 +72,8 @@ export default async function handler( .leftJoin(albumsAssetsAssets, eq(albums.id, albumsAssetsAssets.albumsId)) .leftJoin(assets, and( eq(albumsAssetsAssets.assetsId, assets.id), - eq(assets.isVisible, true), - isNotNull(assets.isArchived), + eq(assets.visibility, "timeline"), + eq(assets.status, "active"), )) .leftJoin(exif, eq(assets.id, exif.assetId)) .leftJoin(assetFaces, eq(assets.id, assetFaces.assetId)) diff --git a/src/pages/api/albums/potential-albums-assets.ts b/src/pages/api/albums/potential-albums-assets.ts index bc860c2..51befd0 100644 --- a/src/pages/api/albums/potential-albums-assets.ts +++ b/src/pages/api/albums/potential-albums-assets.ts @@ -35,7 +35,7 @@ const SELECT_ORPHAN_PHOTOS = (date: string, ownerId: string) => aaa."albumsId" IS NULL AND a."ownerId" = '${ownerId}' AND e."dateTimeOriginal"::date = '${date}' - AND a."isVisible" = true + AND a."visibility" = 'timeline' ORDER BY e."dateTimeOriginal" DESC `); diff --git a/src/pages/api/albums/potential-albums-dates.ts b/src/pages/api/albums/potential-albums-dates.ts index ad37a5e..3cb737a 100644 --- a/src/pages/api/albums/potential-albums-dates.ts +++ b/src/pages/api/albums/potential-albums-dates.ts @@ -25,7 +25,7 @@ export default async function handler( .leftJoin(exif, eq(assets.id, exif.assetId)) .where(and ( eq(assets.ownerId, currentUser.id), - eq(assets.isVisible, true), + eq(assets.visibility, "timeline"), isNull(albumsAssetsAssets.albumsId), isNotNull(exif.dateTimeOriginal), diff --git a/src/pages/api/assets/missing-location-albums.ts b/src/pages/api/assets/missing-location-albums.ts index 20ec3d6..4bca99e 100644 --- a/src/pages/api/assets/missing-location-albums.ts +++ b/src/pages/api/assets/missing-location-albums.ts @@ -35,7 +35,7 @@ export default async function handler( isNotNull(assets.createdAt), isNotNull(exif.dateTimeOriginal), eq(assets.ownerId, currentUser.id), - eq(assets.isVisible, true), + eq(assets.visibility, "timeline"), isNotNull(albums.id) )) .groupBy(albums.id) diff --git a/src/pages/api/assets/missing-location-assets.ts b/src/pages/api/assets/missing-location-assets.ts index 20e391a..66a5d0e 100644 --- a/src/pages/api/assets/missing-location-assets.ts +++ b/src/pages/api/assets/missing-location-assets.ts @@ -39,8 +39,8 @@ const getRowsByDates = async (startDateDate: Date, endDateDate: Date, currentUse gte(exif.dateTimeOriginal, startDateDate), lte(exif.dateTimeOriginal, endDateDate), eq(assets.ownerId, currentUser.id), - eq(assets.isVisible, true), - eq(assets.isArchived, false), + eq(assets.visibility, "timeline"), + eq(assets.status, "active"), isNull(assets.deletedAt), )); } @@ -73,8 +73,8 @@ const getRowsByAlbums = async (currentUser: IUser, albumId: string) => { isNotNull(assets.createdAt), eq(assets.ownerId, currentUser.id), eq(albums.id, albumId), - eq(assets.isVisible, true), - eq(assets.isArchived, false), + eq(assets.visibility, "timeline"), + eq(assets.status, "active"), isNull(assets.deletedAt), )); } diff --git a/src/pages/api/assets/missing-location-dates.ts b/src/pages/api/assets/missing-location-dates.ts index 62b50f8..f194033 100644 --- a/src/pages/api/assets/missing-location-dates.ts +++ b/src/pages/api/assets/missing-location-dates.ts @@ -31,8 +31,8 @@ export default async function handler( isNotNull(assets.createdAt), isNotNull(exif.dateTimeOriginal), eq(assets.ownerId, currentUser.id), - eq(assets.isVisible, true), - eq(assets.isArchived, false), + eq(assets.visibility, "timeline"), + eq(assets.status, "active"), isNull(assets.deletedAt), )) .groupBy(sql`DATE(${exif.dateTimeOriginal})`) diff --git a/src/pages/api/people/list.ts b/src/pages/api/people/list.ts index 8789d5f..76c990f 100644 --- a/src/pages/api/people/list.ts +++ b/src/pages/api/people/list.ts @@ -53,8 +53,8 @@ export default async function handler( const whereClause = and( isNull(assets.duplicateId), - eq(assets.isVisible, true), - eq(assets.isArchived, false), + eq(assets.visibility, "timeline"), + eq(assets.status, "active"), eq(assets.ownerId, currentUser.id), type === "all" ? undefined : (type === "nameless" ? eq(person.name, "") : ne(person.name, "")), query && query.length > 0 ? ilike(person.name, `%${query}%`) : undefined, diff --git a/src/pages/api/rewind/stats.ts b/src/pages/api/rewind/stats.ts index 36daf72..d8dc1fb 100644 --- a/src/pages/api/rewind/stats.ts +++ b/src/pages/api/rewind/stats.ts @@ -26,8 +26,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) const numberOfPhotos = await db.select({ count: count(assets.id) }).from(assets).where(and( eq(assets.ownerId, user.id), - eq(assets.isVisible, true), - eq(assets.isArchived, false), + eq(assets.visibility, "timeline"), + eq(assets.status, "active"), )); // Get list of countries visited in the year @@ -38,8 +38,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) .where(and( eq(sql`EXTRACT(YEAR FROM ${exif.dateTimeOriginal})`, year), eq(assets.ownerId, user.id), - eq(assets.isVisible, true), - eq(assets.isArchived, false), + eq(assets.visibility, "timeline"), + eq(assets.status, "active"), )) .groupBy(exif.country); @@ -52,8 +52,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) .where(and( eq(sql`EXTRACT(YEAR FROM ${exif.dateTimeOriginal})`, year), eq(assets.ownerId, user.id), - eq(assets.isVisible, true), - eq(assets.isArchived, false), + eq(assets.visibility, "timeline"), + eq(assets.status, "active"), )) .groupBy(exif.city); @@ -72,8 +72,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) .where(and( eq(sql`EXTRACT(YEAR FROM ${exif.dateTimeOriginal})`, year), eq(assets.ownerId, user.id), - eq(assets.isVisible, true), - eq(assets.isArchived, false), + eq(assets.visibility, "timeline"), + eq(assets.status, "active"), )) .orderBy(desc(count(assets.id))) .limit(4) @@ -93,8 +93,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) .where(and( eq(sql`EXTRACT(YEAR FROM ${exif.dateTimeOriginal})`, year), eq(assets.ownerId, user.id), - eq(assets.isVisible, true), - eq(assets.isArchived, false), + eq(assets.visibility, "timeline"), + eq(assets.status, "active"), isNotNull(person.name), )) .orderBy(desc(count(assets.id))) @@ -106,9 +106,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) .from(assets) .leftJoin(exif, eq(exif.assetId, assets.id)) .where(and( - eq(assets.isVisible, true), + eq(assets.visibility, "timeline"), eq(assets.isFavorite, true), - eq(assets.isArchived, false), + eq(assets.status, "active"), eq(assets.ownerId, user.id), eq(sql`EXTRACT(YEAR FROM ${exif.dateTimeOriginal})`, year), )) diff --git a/src/pages/api/share-link/[token]/assets.ts b/src/pages/api/share-link/[token]/assets.ts index 9b3892e..dee5525 100644 --- a/src/pages/api/share-link/[token]/assets.ts +++ b/src/pages/api/share-link/[token]/assets.ts @@ -84,8 +84,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) albumIds?.length > 0 ? inArray(albums.id, albumIds) : undefined, startDate ? gte(assets.createdAt, new Date(startDate)) : undefined, endDate ? lte(assets.createdAt, new Date(endDate)) : undefined, - eq(assets.isArchived, false), - eq(assets.isVisible, true), + eq(assets.status, "active"), + eq(assets.visibility, "timeline"), eq(assets.isOffline, false), )) .orderBy(desc(assets.createdAt)); diff --git a/src/pages/api/share-link/[token]/people.ts b/src/pages/api/share-link/[token]/people.ts index 7f8ea77..694ee65 100644 --- a/src/pages/api/share-link/[token]/people.ts +++ b/src/pages/api/share-link/[token]/people.ts @@ -53,8 +53,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) albumIds?.length > 0 ? inArray(albums.id, albumIds) : undefined, startDate ? gte(assets.createdAt, new Date(startDate)) : undefined, endDate ? lte(assets.createdAt, new Date(endDate)) : undefined, - eq(assets.isArchived, false), - eq(assets.isVisible, true), + eq(assets.status, "active"), + eq(assets.visibility, "timeline"), eq(assets.isOffline, false), isNotNull(person.id), ne(person.name, "") diff --git a/src/pages/find/index.tsx b/src/pages/find/index.tsx index 07fe30b..36d87af 100644 --- a/src/pages/find/index.tsx +++ b/src/pages/find/index.tsx @@ -39,7 +39,7 @@ const SUGGESTIONS = [ { label: "Last week's photos", query: "Photos from last week" }, { label: "Photos from last summer", query: "Photos taken last summer" }, { label: "Videos from New York", query: "Videos taken in New York" }, - { label: "Photos with @alex", query: "Photos with @alex" }, // Example with person tag + { label: "Photos taken in Beach", query: "Photos taken in Berlin" }, // Example with person tag { label: "Recent screenshots", query: "Screenshots taken recently" }, ]; diff --git a/src/schema/assets.schema.ts b/src/schema/assets.schema.ts index a436300..791dac8 100644 --- a/src/schema/assets.schema.ts +++ b/src/schema/assets.schema.ts @@ -13,11 +13,11 @@ export const assets = pgTable('assets', { duration: varchar('duration'), encodedVideoPath: varchar('encodedVideoPath').default(''), // checksum: bytea('checksum').notNull(), - isVisible: boolean('isVisible').default(true).notNull(), + visibility: varchar('visibility').default('timeline').notNull(), livePhotoVideoId: uuid('livePhotoVideoId').references((): any => assets.id, { onDelete: 'set null', onUpdate: 'cascade' }), updatedAt: timestamp('updatedAt', { withTimezone: true }).defaultNow().notNull(), createdAt: timestamp('createdAt', { withTimezone: true }).defaultNow().notNull(), - isArchived: boolean('isArchived').default(false).notNull(), + status: varchar('status').default('active').notNull(), originalFileName: varchar('originalFileName').notNull(), sidecarPath: varchar('sidecarPath'), // thumbhash: bytea('thumbhash'),