feat: filter people with different attributes to find faces to hide

Signed-off-by: Varun Raj <mailme@varunraj.in>
This commit is contained in:
Varun Raj committed 2024-08-20 21:45:10 +05:30
1 parent d0dcb00fd8
commit b752bd2322
23 files changed
+558 -141

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
import { pgTable, uuid, integer } from "drizzle-orm/pg-core";
export const assetFaces = pgTable("asset_faces", {
id: uuid("id").defaultRandom().primaryKey(),
assetId: uuid("assetId").notNull(),
personId: uuid("personId"),
imageWidth: integer("imageWidth").notNull().default(0),
imageHeight: integer("imageHeight").notNull().default(0),
boundingBoxX1: integer("boundingBoxX1").notNull().default(0),
boundingBoxY1: integer("boundingBoxY1").notNull().default(0),
boundingBoxX2: integer("boundingBoxX2").notNull().default(0),
boundingBoxY2: integer("boundingBoxY2").notNull().default(0),
});
+1 -1
View File
@@ -28,7 +28,7 @@ export const assets = pgTable('assets', {
isExternal: boolean('isExternal').default(false).notNull(),
deletedAt: timestamp('deletedAt', { withTimezone: true }),
localDateTime: timestamp('localDateTime', { withTimezone: true }).notNull(),
// stackId: uuid('stackId').references(() => assetStack.id, { onDelete: 'set null', onUpdate: 'cascade' }),
stackId: uuid('stackId'),
duplicateId: uuid('duplicateId'),
});
+9
View File
@@ -0,0 +1,9 @@
import { pgTable, uuid, vector } from "drizzle-orm/pg-core";
export const faceSearch = pgTable("face_search", {
faceId: uuid("faceId").notNull(),
embedding: vector("embedding", {
dimensions: 512,
}).notNull(),
});
+5 -1
View File
@@ -1,2 +1,6 @@
export { assets } from './assets.schema';
export { exif } from './exif.schema';
export { exif } from './exif.schema';
export { person } from './person.schema';
export { assetFaces } from './assetFaces.schema';
export { users } from './users.schema';
export * from './relationships';
+14
View File
@@ -0,0 +1,14 @@
import { pgTable, uuid, varchar, timestamp, boolean, date, pgEnum } from "drizzle-orm/pg-core";
export const person = pgTable("person", {
id: uuid("id").defaultRandom().primaryKey(),
createdAt: timestamp("createdAt", { withTimezone: true }).defaultNow(),
updatedAt: timestamp("updatedAt", { withTimezone: true }).defaultNow(),
ownerId: uuid("ownerId").notNull(),
name: varchar("name").notNull().default(''),
thumbnailPath: varchar("thumbnailPath").notNull().default(''),
isHidden: boolean("isHidden").notNull().default(false),
birthDate: date("birthDate", { mode: "date" }),
faceAssetId: uuid("faceAssetId"),
});
+40
View File
@@ -0,0 +1,40 @@
import { relations } from "drizzle-orm";
import { assetFaces } from "./assetFaces.schema";
import { assets } from "./assets.schema";
import { person } from "./person.schema";
import { users } from "./users.schema";
import { faceSearch } from "./faceSearch.schema";
// Assuming there are relations to be defined with `assets` and `person`
export const assetFacesRelations = relations(assetFaces, ({ one }) => ({
asset: one(assets, {
fields: [assetFaces.assetId],
references: [assets.id],
}),
person: one(person, {
fields: [assetFaces.personId],
references: [person.id],
}),
}));
// Assuming there are relations to be defined with `users` and `asset_faces`
export const personRelations = relations(person, ({ one }) => ({
owner: one(users, {
fields: [person.ownerId],
references: [users.id],
}),
faceAsset: one(assetFaces, {
fields: [person.faceAssetId],
references: [assetFaces.id],
}),
}));
// Assuming there are relations to be defined with `asset_faces`
export const faceSearchRelations = relations(faceSearch, ({ one }) => ({
face: one(assetFaces, {
fields: [faceSearch.faceId],
references: [assetFaces.id],
}),
}));
+23
View File
@@ -0,0 +1,23 @@
import { pgTable, uuid, varchar, timestamp, boolean, bigint } from "drizzle-orm/pg-core";
export const users = pgTable("users", {
id: uuid("id").defaultRandom().primaryKey(),
email: varchar("email").notNull(),
password: varchar("password").notNull().default(''),
createdAt: timestamp("createdAt", { withTimezone: true }).defaultNow(),
profileImagePath: varchar("profileImagePath").notNull().default(''),
isAdmin: boolean("isAdmin").notNull().default(false),
shouldChangePassword: boolean("shouldChangePassword").notNull().default(true),
deletedAt: timestamp("deletedAt", { withTimezone: true }),
oauthId: varchar("oauthId").notNull().default(''),
updatedAt: timestamp("updatedAt", { withTimezone: true }).defaultNow(),
storageLabel: varchar("storageLabel"),
name: varchar("name").notNull().default(''),
quotaSizeInBytes: bigint("quotaSizeInBytes", {
mode: 'bigint'
}),
quotaUsageInBytes: bigint("quotaUsageInBytes", {
mode: 'bigint'
}).notNull(),
status: varchar("status").notNull().default('active'),
});